using System.Linq; using System.Collections.Generic; using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var L = int.Parse(line[0]); var r = int.Parse(line[1]); getAns(L, r); } static void getAns(int L, int r) { if (r == 1) { Console.WriteLine(0); return; } var count = 0; foreach (var x in GeneratePrime(2 * r - 1)) { if (x >= L && x <= r) count++; if (x != 2) { var t = (x + 1) / 2; if ((t >= L && t <= r) && (t - 1 >= L && t - 1 <= r)) count++; } } Console.WriteLine(count); } static List GeneratePrime(int m) { var a = new List(); int p; var sqrtMax = Math.Sqrt(m); var s = Enumerable.Range(2, m - 1).ToList(); do { p = s.First(); a.Add(p); s.RemoveAll(n => n % p == 0); } while (p < sqrtMax); a.AddRange(s); return a; } }