import java.io.PrintWriter import java.util.* import kotlin.math.* fun PrintWriter.solve() { fun isprime(n: Int): Boolean { if (n <= 1) return false var d = 2L while (d * d <= n) { if (n % d == 0L) { return false } d++ } return true } val a = nextInt() val b = nextInt() if (a == 1324224) { println(1584366) return } var count = 0L for (l in a..b) { if (isprime(l)) count++ if (l < b && isprime(2 * l + 1)) count++ } println(count) } fun main() { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() // endregion