L,R = map(int,input().split()) C = 2 * R + 2 dat = [0] * C prime = set() i = 2 while i < C: if dat[i] == 0: prime.add(i) for j in range(i * 2,C,i): dat[j] = 1 i += 1 ans = 0 for A in range(L,R + 1): if A in prime: ans += 1 for A in range(L,R): if 2 * A + 1 in prime: ans += 1 print(ans)