class UnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) # 検索 def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] # 併合 def unite(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.rank[x] < self.rank[y]: self.par[x] = y else: self.par[y] = x if self.rank[x] == self.rank[y]: self.rank[x] += 1 # 同じ集合に属するか判定 def same_check(self, x, y): return self.find(x) == self.find(y) l, r = map(int, input().split()) uf = UnionFind(r + 1) t = [0] * (r + 1) for i in range(l, r + 1): if t[i] == 0: for j in range(i * 2, r + 1, i): t[j] = 1 uf.unite(i, j) ans = 0 s = set() for i in range(l, r + 1): p = uf.find(i) if p not in s: ans += 1 s.add(p) print(len(s) - 1)