#!/usr/bin/env python3 # from typing import * import sys import io import math import collections import decimal import itertools import bisect import heapq def input(): return sys.stdin.readline()[:-1] # sys.setrecursionlimit(1000000) # _INPUT = """2 9 # """ # sys.stdin = io.StringIO(_INPUT) INF = 10**10 def get_primes(N): a = [True] * (N + 1) l = [] for n in range(2, N + 1): if a[n]: l.append(n) for i in range(n+n, N + 1, n): a[i] = False return l L, R = map(int, input().split()) primes = get_primes(2*R+2) i1 = bisect.bisect_left(primes, L) j1 = bisect.bisect_left(primes, R+1) ans = j1 - i1 if L < R: i2 = bisect.bisect_left(primes, 2*L+1) j2 = bisect.bisect_left(primes, 2*(R-1)+1+1) ans += j2 - i2 print(ans)