L, R = gets.split(" ").map{|s| s.to_i} n = 2*R-1 prime = Array.new(n+1, true) prime[0] = prime[1] = false 2.upto(n) {|i| if prime[i] then k = 2 while k * i <= n do prime[k*i] = false k += 1 end end } cnt = 0 L.upto(R-1) {|i| cnt += 1 if prime[i] cnt += 1 if prime[2*i+1] } cnt += 1 if prime[R] puts cnt