One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce $x \operatorname{mod} m$ (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. 

The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). 

Given the number of details a on the first day and number m check if the production stops at some moment.


-----Input-----

The first line contains two integers a and m (1 ≤ a, m ≤ 10^5).


-----Output-----

Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No".


-----Examples-----
Input
1 5

Output
No

Input
3 6

Output
Yes

Source: codeforces | Difficulty: MEDIUM
Tags: Mathematics

Matrices

Implementation


Solutions:
(x, m) = map(int, input().split())
x %= m
arr = [False] * m
while not arr[x]:
	arr[x] = True
	x *= 2
	x %= m
print(['Yes', 'No'][x != 0])


from sys import stdin

def iinput():
	return int(stdin.readline())

def sinput():
	return input()

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
(a, m) = minput()
ans = 'No'
for k in range(21):
	if a * 2 ** k % m == 0:
		ans = 'Yes'
		break
print(ans)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
(a, m) = sp()
t = 0
while t <= pow(10, 5):
	if a % m == 0:
		out('Yes')
		exit()
	a += a % m
	t += 1
if a % m == 0:
	out('Yes')
	exit()
out('No')


(a, b) = map(int, input().split(' '))
done = {a}
c = 0
while a != 0:
	c += 1
	if c > 2 * b:
		break
	a += a % b
	if a in done:
		print('Yes')
		exit()
	done.add(a)
print('No')


import sys, os.path
from collections import *
from copy import *
import math
mod = 10 ** 9 + 7
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
(a, m) = map(int, input().split())
d = {}
flag = 0
while 1:
	if a % m == 0:
		flag = 2
		break
	t = a % m
	a += t
	if t not in d:
		d[t] = 1
	else:
		flag = 1
		break
if flag == 1:
	print('No')
if flag == 2:
	print('Yes')


(a, m) = map(int, input().split())
for i in range(10 ** 6):
	if a % m == 0:
		print('Yes')
		exit(0)
	else:
		a += a % m
print('No')


inputs = input()
the_list = list(map(int, inputs.split()))
x = the_list[0]
m = the_list[1]
if 1 <= x <= 10 ** 5 and 1 <= m <= 10 ** 5:
	for y in range(1, 20):
		if x * 2 ** y % m == 0:
			print('Yes')
			break
		elif y == 19 and x * 2 ** y % m != 0:
			print('No')
			break


from fractions import gcd
from sys import stdin
lines = list(filter(None, stdin.read().split('\n')))

def parseline(line):
	return list(map(int, line.split()))
lines = list(map(parseline, lines))
(a, m) = lines[0]
if a * pow(2, m, m) % m != 0:
	print('No')
else:
	print('Yes')


(a, m) = map(int, input().split())
for i in range(int(100000.0) + 10):
	olda = a
	a += a % m
	if a == olda:
		print('Yes')
		exit(0)
print('No')


ip = list((int(n) for n in input().split()))
import math
a = ip[0]
m = ip[1]
while a % 2 == 0 and m % 2 == 0:
	a /= 2
	m /= 2
a %= m
af = [a]
x = 1
k = 1
count = 0
countlimit = 0
m2 = m
while m2 % 2 == 0:
	countlimit += 1
	m2 /= 2
while k == 1:
	a = a * 2 % m
	if a == 0:
		print('Yes')
		k = 0
	else:
		for check in af:
			if a == check:
				print('No')
				k = 0
	if count < countlimit:
		af.append(a)
		count += 1
return


(n, m) = map(int, input().split())
while m % 2 == 0:
	m /= 2
if n % m == 0:
	print('Yes')
else:
	print('No')


(a, m) = map(int, input().split())
import math
s = math.log(m, 2)
i = 0
while i < int(s) + 2:
	if a * 2 ** i % m == 0:
		print('Yes')
		break
	elif i < int(s) + 1:
		i += 1
		continue
	else:
		print('No')
		i += 1


(a, m) = [int(i) for i in input().split()]
loop = set()
while a % m not in loop:
	loop.add(a % m)
	a += a % m
if 0 in loop:
	print('Yes')
else:
	print('No')


(a, m) = map(int, input().split())
for i in range(100000):
	if a % m == 0:
		print('Yes')
		quit()
	else:
		a += a % m
print('No')


(a, m) = list(map(int, str.split(input())))
mem = set()
while a not in mem:
	mem.add(a)
	if a % m == 0:
		print('Yes')
		return
	else:
		a = (a + a % m) % m
print('No')


(a, b) = map(int, input().split())
l1 = [0] * b
flag = 0
a = a % b
while 1:
	if l1[a - 1] == 0:
		l1[a - 1] = 1
		a = (a + a) % b
		if a == 0:
			flag = 1
			break
	else:
		break
if flag == 1:
	print('Yes')
else:
	print('No')


def factory(a, m):
	for i in range(30):
		if a % m == 0:
			return 'Yes'
		else:
			a += a % m
	return 'No'
[a, m] = map(int, input().split())
result = factory(a, m)
print(result)


(a, m) = list(map(int, input().split()))
for i in range(30):
	if a * 2 ** i % m == 0:
		print('Yes')
		exit(0)
print('No')


(a, m) = map(int, input().split())
f = False
for i in range(100000):
	if a % m == 0:
		f = True
		break
	else:
		a += a % m
if f:
	print('Yes')
else:
	print('No')


(a, m) = input().split()
(a, m) = (int(a), int(m))
a %= m
if a == 0:
	print('Yes')
	exit()
if m % a == 0:
	m //= a
if m and (not m & m - 1):
	print('Yes')
else:
	print('No')


(a, m) = map(int, input().split())
for i in range(m):
	b = a % m
	a += b
	if b == 0:
		print('Yes')
		return
print('No')


(a, m) = map(int, input().split())
was = [False for i in range(m)]
was[a % m] = True
a += a % m
while a % m != 0 and (not was[a % m]):
	was[a % m] = True
	a += a % m
print('Yes' if was[0] or a % m == 0 else 'No')


(a, m) = [int(x) for x in input().split()]
if a * pow(2, 1000000000, m) % m == 0:
	print('Yes')
else:
	print('No')


class Factory:

	def __init__(self, product, lim):
		self._product = product
		self._lim = lim
		self._history = set()
		self._delim = False

	def evaluate(self):
		new = self._product % self._lim
		if new == 0:
			self._delim = True
			return False
		if new not in self._history:
			self._history.add(new)
			self._product += new
			return True
		else:
			return False
(a, m) = map(int, input().split())
fact = Factory(a, m)
while fact.evaluate():
	pass
if fact._delim:
	print('Yes')
else:
	print('No')


[a, m] = list(map(int, input().split()))
r = a % m
if r == 0:
	print('Yes')
else:
	while m % 2 == 0:
		m /= 2
	if r % m == 0:
		print('Yes')
	else:
		print('No')


(a, m) = map(int, input().split())
if a * 2 ** 16 % m == 0:
	print('Yes')
else:
	print('No')


import sys
line = input()
v = [int(x) for x in line.split()]
b = [0] * v[1]
while b[v[0] % v[1]] == 0:
	b[v[0] % v[1]] = 1
	v[0] = v[0] * 2 % v[1]
if b[0] == 1:
	print('Yes')
else:
	print('No')


(a, m) = map(int, input().split())
freq = [False for x in range(10 ** 5 + 4)]
y = 2 * (a % m) % m
for _ in range(10 ** 5 + 5):
	y = 2 * y % m
	if y == 0:
		print('Yes')
		exit(0)
print('No')


from collections import defaultdict
from math import *
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
(a, m) = map(int, input().split())
i = 0
isprinted = False
while i < 25:
	if a % m == 0:
		print('Yes')
		isprinted = True
		break
	a += a % m
	i += 1
if isprinted == False:
	print('No')


def factory(a, m):
	flag = 0
	for i in range(20):
		if a % m == 0:
			flag = 1
			break
		a += a % m
	if flag == 1:
		return 'Yes'
	return 'No'
(A, M) = [int(j) for j in input().split()]
print(factory(A, M))


def production_stopped(a, m):
	for _ in range(100000):
		if a % m == 0:
			return 'Yes'
		else:
			a += a % m
	return 'No'
(a, m) = map(int, input().split())
print(production_stopped(a, m))


(a, m) = [int(a) for a in input().split()]
visited = [False] * m
while True:
	visited[a % m] = True
	a = 2 * a % m
	if a == 0:
		print('Yes')
		break
	elif visited[a % m]:
		print('No')
		break


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(a, m) = I()
s = set()
s.add(a)
a += a
ans = 'Yes'
while a not in s:
	s.add(a)
	a = (a + a) % m
if 0 not in s:
	ans = 'No'
print(ans)


(a, m) = [int(x) for x in input().split()]
print('No' if a * 2 ** 20 % m else 'Yes')


def main():
	(a, b) = map(int, input().split())
	s = a
	ok = True
	for i in range(1000000):
		if s % b == 0:
			ok = False
		s = s + s % b
	if ok:
		print('No')
	else:
		print('Yes')
main()


(a, m) = map(int, input().split())
while not m % 2:
	m >>= 1
if a % m == 0:
	print('Yes')
else:
	print('No')


(a, m) = map(int, input().split())
i = 0
f = 0
while i < m:
	if a % m == 0:
		print('Yes')
		f = 1
		break
	a += a % m
	i += 1
if f == 0:
	print('No')


l = list(map(int, input().split()))
a = l[0]
m = l[1]
i = a
i = 2 * i % m
j = 0
while i != 0 and i != a and (j < 2000):
	i = 2 * i % m
	j += 1
if i == 0:
	print('Yes')
else:
	print('No')


(a, m) = map(int, input().split())
for i in range(2 * 10 ** 5):
	a += a % m
if a % m == 0:
	print('Yes')
else:
	print('No')


(a, b) = list(map(int, input().split(' ')))
bad = a
for i in range(133742):
	bad = bad * 2
	if bad % b == 0:
		print('Yes')
		quit()
	else:
		bad %= b
print('No')


(a, m) = map(int, input().split())
for i in range(20):
	if a * 2 ** i % m == 0:
		print('Yes')
		quit()
print('No')


(a, m) = map(int, input().split())
mod = set()
t = 0
while a % m != 0:
	mod.add(a % m)
	a = a + a % m
	t += 1
	if t == m + 100 and len(mod) <= m:
		break
if a % m == 0:
	print('Yes')
else:
	print('No')


def production(a, m, cnt):
	if a % m == 0:
		return True
	if cnt >= 999:
		return False
	return production(a + a % m, m, cnt + 1)

def main():
	(a, m) = map(int, input().split())
	ans = 'Yes' if production(a, m, 0) else 'No'
	print(ans)
main()


(a, m) = map(int, input().split())
k = 0
for i in range(1000000):
	a = a + a % m
	if a % m == 0:
		k += 1
		break
if k == 0:
	print('No')
else:
	print('Yes')


(a, m) = map(int, input().split())
c = 0
for i in range(pow(10, 5)):
	if a % m == 0:
		c = 1
		break
	else:
		a = a + a % m
if c == 1:
	print('Yes')
else:
	print('No')


(a, m) = map(int, input().split())
print(['Yes', 'No'][(a << 17) % m > 0])


(a, m) = map(int, input().split())
s = set()
s.add(a)
while True:
	a = 2 * a % m
	if a in s:
		print('No')
		exit(0)
	if a == 0:
		print('Yes')
		exit(0)
	s.add(a)


(a, m) = map(int, input().split())
r = a
ans = 0
for i in range(10 ** 6):
	r += r % m
	if r % m == 0:
		ans = 1
if ans:
	print('Yes')
else:
	print('No')


def solve():
	(a, m) = map(int, input().split())
	visited = [False] * m
	rem = m
	while rem != 0:
		rem = a % m
		if rem == 0:
			return True
		if visited[rem]:
			return False
		else:
			visited[rem] = True
			a = (a + rem) % m
if solve():
	print('Yes')
else:
	print('No')


(a, m) = map(int, input().split())

def f(x):
	for i in range(m):
		x = 2 * x % m
		if not x:
			return 'Yes'
	return 'No'
print(f(a))


(n, k) = map(int, input().split())
a = [0] * k
for i in range(k):
	if n % k == 0:
		exit(print('Yes'))
	if a[n % k] != 1:
		a[n % k] = 1
		n += n % k
	else:
		exit(print('No'))
print('Yes')


from math import log
(a, x) = map(int, input().split())
if a * 2 ** int(log(x) / log(2)) % x == 0:
	print('Yes')
else:
	print('No')


import os
import sys
from io import BytesIO, IOBase

def main():
	(a, b) = map(int, input().split(' '))
	done = {a}
	cnt = 0
	while a != 0:
		cnt += 1
		if cnt > 2 * b:
			break
		a = a + a % b
		if a in done:
			print('Yes')
			return
		done.add(a)
	print('No')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


l = list(map(int, input().split()))
a = l[0]
m = l[1]
f = False
i = 1
while i <= 17 and f == False:
	if a % m == 0:
		print('Yes')
		f = True
	else:
		a *= 2
	i += 1
if f == False:
	print('No')


(x, y) = map(int, input().split())
s = x
f = 0
for i in range(100001):
	if s % y == 0:
		f = 1
	s = s + s % y
if f == 0:
	print('No')
else:
	print('Yes')


(a, m) = map(int, input().split())
ans = 0
for i in range(25):
	if a % m == 0:
		ans = 1
		break
	a += a % m
if ans == 1:
	print('Yes')
else:
	print('No')


import math
(a, m) = [int(i) for i in input().split()]
i = 0
while i <= 10000000.0:
	a += a % m
	if a % m == 0:
		print('Yes')
		break
	if i == 100000.0:
		print('No')
		break
	i += 1


(a, m) = map(int, input().split())
for i in range(21):
	a += a % m
if a % m:
	print('No')
else:
	print('Yes')


from sys import stdin
__author__ = 'artyom'
(a, m) = map(int, stdin.readline().strip().split())
rem = a % m
z = set()
z.add(rem)
while rem > 0:
	a += rem
	rem = a % m
	if rem in z:
		print('No')
		exit()
	z.add(rem)
print('Yes')


import sys
inp = input('').split()
details = int(inp[0])
number = int(inp[1])
remainders = set()
prev_day = details
for i in range(number):
	val = prev_day % number
	if val in remainders:
		print('No')
		exit(0)
	elif val == 0:
		print('Yes')
		exit(0)
	remainders.add(val)
	prev_day = prev_day + val


def factory(a, m):
	s = set()
	while a % m != 0:
		r = a % m
		if r in s:
			return False
		else:
			a += r
			s.add(r)
	return True
(a, m) = map(int, input().split())
if factory(a, m):
	print('Yes')
else:
	print('No')


import time
l = list(map(int, input().split()))
t = time.time()
a = l[0]
m = l[1]
l = []
d = 'NO'
while True:
	a += a % m
	if a % m == 0:
		d = 'Yes'
		break
	if time.time() - t > 0.8:
		d = 'No'
		break
print(d)


(a, m) = map(int, input().split())
ar = [0] * m
while ar[a % m] == 0:
	ar[a % m] = 1
	a += a % m
if ar[0] == 1:
	print('Yes')
else:
	print('No')


(x, m) = [int(x) for x in input().split()]
mod = x % m
s = set()
s.add(mod)
x = x + mod
while x % m != 0 and x % m not in s:
	s.add(x % m)
	x = x + x % m
if x % m == 0:
	print('Yes')
elif x % m in s:
	print('No')


import math
(n, m) = map(int, input().split())
p = 0
k = 0
while p == 0 and k <= int(math.log(m, 2)):
	if n * pow(2, k) % m == 0:
		p = 1
		print('Yes')
	else:
		k += 1
if p != 1:
	print('No')


(a, m) = [int(i) for i in input().split()]
for i in range(m + 100):
	if a % m != 0:
		a = a + a % m
	else:
		print('Yes')
		exit(0)
print('No')


(a, m) = [int(v) for v in input().split()]
x = a % m
while m % 2 == 0:
	m = m / 2
if a % m == 0:
	print('Yes')
else:
	print('No')


(a, m) = input().split()
a = int(a)
m = int(m)
if m < 3 and a % m == 0:
	print('Yes')
else:
	for k in range(1, 21):
		if (1 << k) * a % m == 0:
			print('Yes')
			exit()
	print('No')


from math import log

def main(a, m):
	for k in range(500 + 3 * int(log(m))):
		if a * 2 ** k % m == 0:
			return True
	return False
print('Yes' if main(*list(map(int, input().split(' ')))) else 'No')


(a, m) = map(int, input().split())
s = set()
flag = 0
while 1:
	if a > m:
		a %= m
		if a in s:
			break
		s.add(a)
	a *= 2
	if a == 0:
		flag = 1
		break
if flag:
	print('Yes')
else:
	print('No')


def call(a, m):
	if a == m:
		return 'Yes'
	if a % m == 0:
		return 'Yes'
	if a > m:
		return 'No'
	for i in range(18):
		a = a * 2
		if a % m == 0:
			return 'Yes'
	return 'No'
(a, m) = map(int, input().split())
print(call(a, m))


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
mod = 10 ** 9 + 7
(a, m) = R()
l = len(str(m))
for i in range(5 * l + 100):
	if (a << i) % m == 0:
		print('Yes')
		exit()
print('No')


(a, m) = map(int, input().split())
for x in range(25):
	a += a % m
	if a % m == 0:
		print('Yes')
		exit()
print('No')


from sys import stdin, stdout

def solve():
	(a, m) = map(int, stdin.readline().split())
	vis = [0 for i in range(m)]
	mod = a % m
	while vis[mod] == 0:
		vis[mod] = 1
		mod = mod * 2 % m
	print('Yes' if vis[0] else 'No')
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip()) if LOCAL_TEST else 1
t = 1
while t <= tcs:
	solve()
	t += 1


import sys
input = lambda : sys.stdin.readline()
MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : list(map(int, input().split()))
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(a, m) = f()
c = 0
while a % m != 0:
	a += a % m
	c += 1
	if c > 10 ** 6:
		break
print('YNeos'[a % m != 0::2])


(a, m) = map(int, input().rstrip().split())
for i in range(m):
	rem = a % m
	if rem == 0:
		print('Yes')
		exit()
	a += rem
print('No')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
q = inlt()
a = q[0]
m = q[1]
while m % 2 == 0:
	m = m // 2
if a % m == 0:
	print('Yes')
else:
	print('No')


[a, m] = input().split(' ')
(a, m) = (int(a), int(m))
a = a % m
rem = set([])
rem.add(a)
while 2 * a % m not in rem:
	a = 2 * a % m
	rem.add(a)
if 0 in rem:
	print('Yes')
else:
	print('No')


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
(details, mods) = RMI()
starts = set()
ans = 'Yes'
while details % mods != 0:
	current = details % mods
	if current in starts:
		ans = 'No'
		break
	else:
		starts.add(current)
		details += details % mods
print(ans)


class CodeforcesTask485ASolution:

	def __init__(self):
		self.result = ''
		self.a_m = []

	def read_input(self):
		self.a_m = [int(x) for x in input().split(' ')]

	def process_task(self):
		t = 0
		limit = 10 ** 6
		(x, m) = self.a_m
		while x % m and t < limit:
			x += x % m
			t += 1
		self.result = 'Yes' if t < limit else 'No'

	def get_result(self):
		return self.result
Solution = CodeforcesTask485ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(a, m) = map(int, input().split())
x = a
saved = set()
while x != 0:
	saved.add(x)
	x += x % m
	x %= m
	if x in saved:
		print('No')
		break
else:
	print('Yes')


[a, m] = [int(x) for x in input().split()]
flag = True
for i in range(500):
	p = a % m
	if p == 0:
		flag = False
		break
	a += p
print('Yes') if not flag else print('No')


import math
(a, m) = map(int, input().split())
k = math.log(m, 2)
k = int(round(k, 0))
flag = 0
for i in range(k + 1):
	if a * int(math.pow(2, i)) % m == 0:
		flag = 1
		break
if flag == 1:
	print('Yes')
else:
	print('No')


ri = lambda : map(int, input().split(' '))
(a, m) = ri()
for _ in range(25):
	if a == 0:
		print('Yes')
		import sys
		sys.exit(0)
	a = a * 2
	a = a % m
print('No')


(a, m) = map(int, input().split())
print('No' if (a << 17) % m else 'Yes')


import sys
(a, m) = map(int, input().split())
d = set()
for i in range(10 ** 7):
	d.add(a % m)
	a += a % m
	if a % m == 0:
		print('Yes')
		sys.exit(0)
	if a % m in d:
		print('No')
		sys.exit(0)


(a, m) = map(int, input().split())
x = 0
while a % m != 0 and x != m:
	a += a % m
	x += 1
print('Yes') if a % m == 0 else print('No')


import math

def res():
	(n, m) = map(int, input().split())
	k = math.floor(math.log(m, 2)) + 2
	i = 1
	t = n
	f = 1
	while i <= k:
		if t % m == 0:
			f = 0
			break
		t = t * 2
		i = i + 1
	if f == 0:
		print('Yes')
	else:
		print('No')
res()


x = input().split()
a = int(x[0])
m = int(x[1])
l = []
i = 0
while i < m:
	l.append(a % m)
	a += a % m
	i += 1
if 0 in l:
	print('Yes')
else:
	print('No')


def f(l):
	(a, m) = l
	for i in range(m):
		x = a % m
		if x == 0:
			return 'Yes'
		a += x
	return 'No'
l = list(map(int, input().split()))
print(f(l))


import bisect
(a, m) = map(int, input().strip().split())
seen = []
while bisect.bisect_left(seen, a) == bisect.bisect_right(seen, a) and len(seen) < 20:
	if a % m == 0:
		print('Yes')
		break
	bisect.insort_left(seen, a)
	a = 2 * a % m
else:
	print('No')


(n, m) = map(int, input().split())
q = {-1}
while n % m not in q:
	q.add(n % m)
	n += n % m
print('YNeos'[0 not in q::2])


(a, m) = input().split(' ')
(a, m) = (int(a), int(m))
d = set()
d.add(a % m)
while a % m != 0:
	a += a % m
	if a % m in d:
		print('No')
		break
	d.add(a % m)
if not a % m:
	print('Yes')


string = input()
numbers = string.split()
(a, b) = (int(numbers[0]), int(numbers[1]))
n = a % b
while b % 2 == 0:
	b //= 2
if n % b == 0:
	print('Yes')
else:
	print('No')


x = input().split()
a = int(x[0])
m = int(x[1])
mod = 0
result = 0
if m != 1:
	for value in range(1, m):
		mod = a % m
		a += mod
		if mod == 0:
			result = 1
			break
	if result == 1:
		print('Yes')
	else:
		print('No')
else:
	print('Yes')


a = input()
a = a.split()
b = int(a[0])
c = int(a[1])
s = [b % c, (b + b % c) % c, (b + (b + b % c) % c) % c]
resto = b % c
num = 1
k = 0
while resto != 0:
	b = b + resto
	resto = b % c
	k = k + 1
	if resto == 0:
		break
	if k > c:
		if resto == s[2] or resto == s[1] or resto == s[0]:
			num = 0
			break
	if k == c:
		num = 0
		break
if num == 0:
	print('No')
else:
	print('Yes')


(a, m) = map(int, input().split())
ans = 'No'
for _ in range(m):
	if a % m == 0:
		ans = 'Yes'
		break
	else:
		a += a % m
print(ans)


(n, m) = map(int, input().split())
a = n
t = 1
days = 100
while days:
	if n * t % m == 0:
		print('Yes')
		exit(0)
	t *= 2
	days -= 1
print('No')


import sys
import math
(a, m) = list(map(int, input().split()))
if a % m == 0 or 2 * a % m == 0:
	print('Yes')
	return
a1 = a
f = False
for k in range(int(math.log(m, 2)) + 1):
	if a * 2 ** k % m == 0:
		f = True
		break
if f:
	print('Yes')
else:
	print('No')


y = input('').split(' ')
a = int(y[0])
m = int(y[1])
while m % 2 == 0:
	m = m / 2
if a % m == 0:
	print('Yes')
else:
	print('No')


lis = input().split()
a = int(lis[0])
m = int(lis[1])
if m % 2 == 1:
	if a % m == 0:
		print('Yes')
	else:
		print('No')
else:
	k = 0
	while 2 ** k <= m and m % 2 ** k == 0:
		k += 1
	k -= 1
	u = m // 2 ** k
	if a % m % u == 0:
		print('Yes')
	else:
		print('No')


ip = list((int(n) for n in input().split()))
import math
a = ip[0]
m = ip[1]
a %= m
af = [a]
x = 1
k = 1
count = 0
countlimit = int(math.floor(math.log(m, 2)))
while k == 1:
	a = (a + a % m) % m
	if a == 0:
		print('Yes')
		k = 0
	else:
		for check in af:
			if a == check:
				print('No')
				k = 0
	if count <= countlimit:
		af.append(a)
		count += 1
exit()


(a, b) = map(int, input().split())
flag = 0
for i in range(21):
	a = a * 2 ** i
	if a % b == 0:
		flag = 1
		break
if flag == 1:
	print('Yes')
else:
	print('No')


(a, m) = list(map(int, input().split()))
s = set()
while True:
	a %= m
	if a in s:
		print('Yes' if 0 in s else 'No')
		break
	s.add(a)
	a *= 2


(n, m) = input().split()
n = int(n)
m = int(m)
for i in range(0, 10 ** 5):
	n += n % m
	if n % m == 0:
		break
if n % m == 0:
	print('Yes')
else:
	print('No')


import sys
(a, m) = input().split()
a = int(a)
m = int(m)
r = []
e = 0
c = 0
while e not in r:
	e = a % m
	a += e
	if e == 0:
		print('Yes')
		sys.exit()
	c += 1
	if c == 1000000:
		break
print('No')


def main():
	(a, m) = map(int, input().split())
	for _ in range(m):
		a = a * 2 % m
		if not a:
			print('Yes')
			return
	print('No')
main()


(a, m) = map(int, input().split())
arr = []
x = a
new = a % m
arr.append(new)
a += new
if new == 0:
	print('Yes')
	exit(0)
while len(arr) < 100000:
	new = a % m
	if new == 0:
		print('Yes')
		exit(0)
	elif new == arr[0]:
		print('No')
		exit(0)
	else:
		a += new
		a = a % m
		arr.append(a)
print('No')


(a, m) = map(int, input().split())
for i in range(1, 21):
	if a % m == 0:
		print('Yes')
		exit()
	a *= 2
print('No')


lst = input().split()
a = int(lst[0])
m = int(lst[1])
if a * 2 ** 20 % m:
	print('No')
else:
	print('Yes')


import sys
(a, m) = map(int, sys.stdin.readline().split())
f = 0
for i in range(100000):
	if a % m == 0:
		f = 1
		break
	else:
		a = a + a % m
if f == 1:
	print('Yes')
else:
	print('No')


from fractions import gcd
from sys import stdin
lines = list([_f for _f in stdin.read().split('\n') if _f])

def parseline(line):
	return list(map(int, line.split()))
lines = list(map(parseline, lines))
(a, m) = lines[0]
if a * pow(2, m, m) % m != 0:
	print('No')
else:
	print('Yes')


(a, m) = list(map(int, input().split()))
found = {}
found[a % m] = True
cur = a
while True:
	cur = cur + cur % m
	if cur % m == 0:
		print('Yes')
		break
	if cur % m in found:
		print('No')
		break
	found[cur % m] = True


(a, m) = map(int, input().split())
flag = 'No'
for i in range(10000):
	if a % m == 0:
		flag = 'Yes'
		break
	a += a % m
print(flag)


(a, m) = [int(i) for i in input().split()]
x = a % m
ans = x + a
i = 0
while i != 30:
	if ans % m == 0:
		print('Yes')
		break
	else:
		ans = ans * 2
		i += 1
else:
	print('No')


s = input()
(a, n) = s.split()
a = int(a)
n = int(n)
if a >= n:
	a = a % n
	if a == 0:
		print('Yes')
		exit()
b = 1
while b < n:
	b = b * 2
if b == n:
	print('Yes')
	exit()
while a < n:
	a = a * 2
if a == n:
	print('Yes')
else:
	print('No')


import array

def solution():
	book = {}
	numbers = input().split(' ')
	first = int(numbers[0])
	second = int(numbers[1])
	first = first % second
	while first:
		first = first * 2 % second
		if first in book:
			print('No')
			return
		else:
			book[first] = 0
	print('Yes')

def count_of_one(number):
	result = 0
	while number:
		result += number % 2
		number //= 2
	return result

def to_mixed_frac(first, second):
	while True:
		for i in range(2, first + 1):
			if first % i == 0 and second % i == 0:
				first //= i
				second //= i
				break
		else:
			break
	return str(first) + '/' + str(second)

def array_to_int(array):
	for i in range(len(array)):
		array[i] = int(array[i])
	return array

def join0(array):
	result = ''
	for i in array:
		result += str(i)
	return result

def replace(string, new_ch, index):
	new_str = ''
	for i in range(len(string)):
		if i == index:
			new_str += new_ch
		else:
			new_str += string[i]
	return new_str
solution()


(a, m) = map(int, input().split())
i = 0
flag = False
while i < 50:
	if a % m != 0:
		a += a % m
	else:
		flag = True
	i += 1
if flag == False:
	print('No')
else:
	print('Yes')


(a, m) = map(int, input().split())
x = set()
while True:
	v = a % m
	if v == 0:
		print('Yes')
		break
	elif v in x:
		print('No')
		break
	else:
		x.add(v)
		a += v


(a, b) = map(int, input().split())
i = 1
while i < 100:
	x = a % b
	if x == 0:
		print('Yes')
		break
	a += x
	i += 1
else:
	print('No')


import sys
from math import sqrt
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(a, m) = map(int, input().split())
MAX = 100000
no = a
res = False
for i in range(MAX):
	no = no + no % m
	if no % m == 0:
		res = True
		break
print('Yes' if res else 'No')


(a, m) = map(int, input().split())
f = 1
while a <= 10 ** 7:
	a1 = a + a % m
	if a1 == a:
		f = 0
		break
	a = a1
if f:
	print('No')
else:
	print('Yes')


(x, m) = map(int, input().split())
f = 0
for i in range(m):
	if x % m == 0:
		print('Yes')
		f = 1
		break
	else:
		x = x + x % m
if f == 0:
	print('No')


(a, b) = list(map(int, input().split()))
c = {a}
d = True
while a:
	a = a * 2 % b
	if a in c:
		d = False
		break
	c |= {a}
print('Yes' if d else 'No')


def solve():
	(a, m) = map(int, input().split())
	reached = [False] * m
	for i in range(m + 1):
		if a == 0:
			return 'Yes'
		else:
			a = a * 2 % m
	return 'No'
print(solve())


(a, m) = map(int, input().split())
pm = set()
while a % m not in pm:
	pm.add(a % m)
	a += a % m
if 0 not in pm:
	print('No')
else:
	print('Yes')


import math

def solve():
	(a, m) = map(int, input().split(' '))
	while m % 2 == 0:
		m /= 2
	print(['No', 'Yes'][a % m == 0])

def main():
	solve()
main()


(n, k) = map(int, input().split())
d = {}
while 1:
	if n % k == 0:
		print('Yes')
		break
	if n not in d:
		d[n] = 1
	else:
		print('No')
		break
	n = n * 2 % k


(n, m) = map(int, input().split())
a = [False] * m
n %= m
while a[n] == False:
	a[n] = True
	n = (n + n) % m
print('Yes') if a[0] else print('No')


L = input()
L = L.split()
a = int(L[0])
m = int(L[1])
R = [a % m, (a + a % m) % m, (a + (a + a % m) % m) % m]
res = a % m
aux = 1
k = 0
while res != 0:
	a = a + res
	res = a % m
	k += 1
	if res == 0:
		break
	if k > m:
		if res == R[0] or res == R[1] or res == R[2]:
			aux = 0
			break
	if k == m:
		aux = 0
		break
if aux == 0:
	print('No')
else:
	print('Yes')