class UF_tree: def __init__(self, n): self.root = [-1] * (n + 1) self.rank = [0] * (n + 1) def find(self, x): if self.root[x] < 0: return x else: self.root[x] = self.find(self.root[x]) return self.root[x] def isSame(self, x, y): return self.find(x) == self.find(y) def unite(self, x, y): x = self.find(x) y = self.find(y) if x == y: return elif self.rank[x] < self.rank[y]: self.root[y] += self.root[x] self.root[x] = y else: self.root[x] += self.root[y] self.root[y] = x if self.rank[x] == self.rank[y]: self.rank[x] += 1 def size(self, x): return - self.root[self.find(x)] L, R = map(int, input().split()) size = R - L + 1 uf = UF_tree(R + 1) for i in range(L, R + 1): v = i * 2 while v <= R: uf.unite(i, v) v += i cost = 0 for i in range(L, R): if uf.isSame(i, i + 1): continue uf.unite(i, i + 1) cost += 1 print(cost)