using System; namespace Csharp { class Program { static bool[] IsChecked = new bool[1000001]; static bool[] IsSquare = new bool[1000001]; static void Main(string[] args) { var inputs = Console.ReadLine().Split(); long min = Convert.ToInt64(inputs[0]); long max = Convert.ToInt64(inputs[1]); long ans = max - min + 1; for (long i = 2; i * i <= max; ++i) { if (IsChecked[i]) continue; for (long j = i; j * j<= max; j += i) IsChecked[j] = true; long square = i * i; for (long j = ((min - 1) / square + 1) * square; j <= max; j += square) { if (IsSquare[j - min] == false) { IsSquare[j - min] = true; --ans; } } } Console.WriteLine(ans); } } } |