l, r = map(int, input().split()) def Sieve_of_Eratosthenes(maxA): lst = [None]*(maxA+1) lst[0] = False lst[1] = False for i in range(2, maxA+1): if lst[i] is None: for g in range(i, maxA+1, i): if lst[g] is None: lst[g] = False lst[i] = True return lst lst = Sieve_of_Eratosthenes(2*r+1) ans = int(lst[r]) for i in range(l, r): ans += lst[i] ans += lst[2*i+1] print(ans)