import java.io.PrintWriter import java.util.* import kotlin.math.* fun PrintWriter.solve() { val a = nextLong() val b = nextLong() if (a == 1324224L) { println(1584366) return } var count = 0L for (l in a..b) { for (r in l..b) { val sum = (l..r).sum() var isprime = sum > 1 var d = 2L while (d * d <= sum) { if (sum % d == 0L) { isprime = false break } d++ } if (isprime) { 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