from collections import defaultdict, deque n, p = map(int, input().split()) div = [None for _ in range(n + 1)] div[1] = 1 for x in range(2, n + 1): if not div[x] is None: continue div[x] = x for y in range(2, n // x + 1): if div[x * y] is None: div[x * y] = x # print(div) used = defaultdict(bool) dq = deque() cur = p while cur > 1: if not used[div[cur]]: used[div[cur]] = True dq.appendleft(div[cur]) cur //= div[cur] while len(dq) > 0: cur = dq.pop() for y in range(2, n // cur + 1): if y == div[y] and not used[y]: used[y] = True dq.appendleft(y) used[cur * y] = True print(len(used))