from math import * def Sieve(n): lst = [True] * (n + 1) S = set() for i in range(2, ceil(sqrt(n)) + 1): if lst[i]: for j in range(2 * i, n + 1, i): lst[j] = False for i in range(2, n + 1): if lst[i]: S.add(i) return S L, R = map(int, input().split()) S = Sieve(2020202) ans = 0 for i in range(L, R + 1): if i in S: ans += 1 if 2 * i + 1 in S: ans += 1 print(ans)