Fox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was represented by string s. Each character of s is one move operation. There are four move operations at all:  'U': go up, (x, y)  →  (x, y+1);  'D': go down, (x, y)  →  (x, y-1);  'L': go left, (x, y)  →  (x-1, y);  'R': go right, (x, y)  →  (x+1, y). 

The robot will do the operations in s from left to right, and repeat it infinite times. Help Fox Ciel to determine if after some steps the robot will located in (a, b).


-----Input-----

The first line contains two integers a and b, ( - 10^9 ≤ a, b ≤ 10^9). The second line contains a string s (1 ≤ |s| ≤ 100, s only contains characters 'U', 'D', 'L', 'R') — the command.


-----Output-----

Print "Yes" if the robot will be located at (a, b), and "No" otherwise.


-----Examples-----
Input
2 2
RU

Output
Yes

Input
1 2
RU

Output
No

Input
-1 1000000000
LRRLU

Output
Yes

Input
0 0
D

Output
Yes



-----Note-----

In the first and second test case, command string is "RU", so the robot will go right, then go up, then right, and then up and so on.

The locations of its moves are (0, 0)  →  (1, 0)  →  (1, 1)  →  (2, 1)  →  (2, 2)  →  ...

So it can reach (2, 2) but not (1, 2).

Difficulty: MEDIUM_HARD
Tags: Mathematics

Sorting

Implementation
Skill types: Sorting

Starter code:

Solutions:
from math import hypot
(a, b) = map(int, input().split())
s = input().strip()
(dx, dy) = (0, 0)
for i in s:
	if dx == a and dy == b:
		print('Yes')
		exit()
	if i == 'R':
		dx += 1
	if i == 'L':
		dx -= 1
	if i == 'D':
		dy -= 1
	if i == 'U':
		dy += 1
	if dx == a and dy == b:
		print('Yes')
		exit(0)
if dx == dy == 0:
	print('No')
	exit(0)
lngt = int(max(0, hypot(a, b) / hypot(dx, dy) - 500))
(x, y) = (dx * lngt, dy * lngt)
for j in range(1000):
	for i in s:
		if x == a and y == b:
			print('Yes')
			exit(0)
		if i == 'R':
			x += 1
		if i == 'L':
			x -= 1
		if i == 'D':
			y -= 1
		if i == 'U':
			y += 1
		if x == a and y == b:
			print('Yes')
			exit(0)
print('No')


import operator
table = {'U': (0, 1), 'D': (0, -1), 'L': (-1, 0), 'R': (1, 0)}
(a, b) = list(map(int, input().split()))
s = list(input())
zs = set()
(x, y) = (0, 0)
zs.add((x, y))
for c in s:
	(x, y) = list(map(operator.add, (x, y), table[c]))
	zs.add((x, y))
result = False
for (zx, zy) in zs:
	(p, q) = (a - zx, b - zy)
	if x == 0 and p != 0 or (x != 0 and p % x != 0) or (x != 0 and p // x < 0):
		continue
	if y == 0 and q != 0 or (y != 0 and q % y != 0) or (y != 0 and q // y < 0):
		continue
	if x != 0 and y != 0 and (p // x != q // y):
		continue
	result = True
print('Yes' if result else 'No')


dx = {'U': 0, 'D': 0, 'L': -1, 'R': 1}
dy = {'U': 1, 'D': -1, 'L': 0, 'R': 0}
(x, y, xl, yl) = (0, 0, [], [])
(a, b) = map(int, input().split())
for ch in input():
	xl.append(x)
	yl.append(y)
	x += dx[ch]
	y += dy[ch]
for (xi, yi) in zip(xl, yl):
	(mx, my) = (a - xi, b - yi)
	if x == 0 and mx != 0 or (x != 0 and (mx % x != 0 or mx // x < 0)):
		continue
	if y == 0 and my != 0 or (y != 0 and (my % y != 0 or my // y < 0)):
		continue
	if x != 0 and y != 0 and (mx // x != my // y):
		continue
	print('Yes')
	exit()
print('No')


def minus_two(x, y):
	return [x[0] - y[0], x[1] - y[1]]

def will_reach(loc, commands):
	new_loc = [0, 0]
	possible_locs = [[0, 0]]
	for c in commands:
		if c == 'U':
			new_loc[1] += 1
		elif c == 'D':
			new_loc[1] -= 1
		elif c == 'R':
			new_loc[0] += 1
		elif c == 'L':
			new_loc[0] -= 1
		possible_locs += [list(new_loc)]
	all_destinations = [minus_two(loc, pl) for pl in possible_locs]
	for destination in all_destinations:
		realdx = destination[0]
		realdy = destination[1]
		reqdx = new_loc[0]
		reqdy = new_loc[1]
		if destination == [0, 0]:
			return True
		if reqdx != 0 and realdx != 0:
			if realdy / realdx == reqdy / reqdx and (realdy > 0 and reqdy > 0 or (realdy < 0 and reqdy < 0)) and (realdy / reqdy == int(realdy / reqdy)) and (realdx / reqdx == int(realdx / reqdx)):
				return True
		if realdy == reqdy and realdx == reqdx:
			return True
		if reqdx == 0 and realdx == 0:
			if (reqdy > 0 and realdy > 0 or (reqdy < 0 and realdy < 0)) and realdy / reqdy == int(realdy / reqdy):
				return True
		if reqdy == 0 and realdy == 0:
			if (reqdx > 0 and realdx > 0 or (reqdx < 0 and realdx < 0)) and realdx / reqdx == int(realdx / reqdx):
				return True
	return False

def will_reach2(loc, commands):
	new_loc = [0, 0]
	available_loc = []
	for c in commands:
		if c == 'U':
			new_loc[1] += 1
		elif c == 'D':
			new_loc[1] -= 1
		elif c == 'R':
			new_loc[0] += 1
		elif c == 'L':
			new_loc[0] -= 1
		available_loc += [new_loc]
	realdx = new_loc[0]
	realdy = new_loc[1]
	reqdx = loc[0]
	reqdy = loc[1]
	print('realdx', realdx)
	print('realdy', realdy)
	print('reqdx', reqdx)
	print('reqdy', reqdy)
	if reqdx != 0 and realdx != 0:
		return realdy / realdx == reqdy / reqdx
	elif reqdx == 0 and realdx == 0:
		return reqdy / realdy > 0
	else:
		return False

def main():
	first_line = input()
	first_line = first_line.split()
	loc = [int(first_line[0]), int(first_line[1])]
	cmds = input()
	if will_reach(loc, cmds):
		print('Yes')
	else:
		print('No')
main()


(a, b) = map(int, input().split())
s = str(input())
sl = len(s)
x = [0 for i in range(101)]
y = [0 for i in range(101)]
for i in range(sl):
	x[i + 1] = x[i]
	y[i + 1] = y[i]
	if s[i] == 'U':
		y[i + 1] += 1
	elif s[i] == 'D':
		y[i + 1] -= 1
	elif s[i] == 'L':
		x[i + 1] -= 1
	else:
		x[i + 1] += 1
for i in range(0, sl):
	if x[sl] == 0:
		if a == x[i]:
			if y[sl] == 0 and b == y[i] or (y[sl] != 0 and (b - y[i]) % y[sl] == 0 and ((b - y[i]) // y[sl] >= 0)):
				print('Yes')
				exit()
	elif (a - x[i]) % x[sl] == 0 and (a - x[i]) // x[sl] >= 0 and (b == y[i] + (a - x[i]) // x[sl] * y[sl]):
		print('Yes')
		exit()
print('No')


class CodeforcesTask321ASolution:

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

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

	def process_task(self):
		vector = [0, 0]
		for c in self.command:
			if c == 'U':
				vector[1] += 1
			elif c == 'D':
				vector[1] -= 1
			elif c == 'R':
				vector[0] += 1
			elif c == 'L':
				vector[0] -= 1
		if vector[0] and vector[1]:
			turns_away = min(self.a_b[0] // vector[0], self.a_b[1] // vector[1])
		elif vector[0]:
			turns_away = self.a_b[0] // vector[0]
		elif vector[1]:
			turns_away = self.a_b[1] // vector[1]
		else:
			turns_away = 0
		turns_away = max(turns_away - 50, 0)
		x = vector[0] * turns_away
		y = vector[1] * turns_away
		can = False
		if x == self.a_b[0] and y == self.a_b[1]:
			can = True
		for z in range(100):
			for c in self.command:
				if c == 'U':
					y += 1
				elif c == 'D':
					y -= 1
				elif c == 'R':
					x += 1
				elif c == 'L':
					x -= 1
				if x == self.a_b[0] and y == self.a_b[1]:
					can = True
		self.result = 'Yes' if can else 'No'

	def get_result(self):
		return self.result

def __starting_point():
	Solution = CodeforcesTask321ASolution()
	Solution.read_input()
	Solution.process_task()
	print(Solution.get_result())
__starting_point()


(a, b) = map(int, input().split())
s = input()
xi = 0
yi = 0
error = 0
for i in s:
	if i == 'R':
		xi += 1
	elif i == 'L':
		xi -= 1
	elif i == 'D':
		yi -= 1
	elif i == 'U':
		yi += 1
if xi != 0:
	num = a // xi
	if num > -1:
		if yi != 0:
			if a % xi == 0 and num * yi == b:
				error = 1
		elif a % xi == 0 and b == 0:
			error = 1
else:
	num = 0
	if yi != 0:
		if a == 0 and b % yi == 0 and (b // yi >= 0):
			error = 1
	elif a == 0 and b == 0:
		error = 1
xi2 = 0
yi2 = 0
for i in s:
	if i == 'R':
		xi2 += 1
	elif i == 'L':
		xi2 -= 1
	elif i == 'D':
		yi2 -= 1
	elif i == 'U':
		yi2 += 1
	if xi != 0:
		num = (a - xi2) // xi
		if num > -1:
			if yi != 0:
				if (a - xi2) % xi == 0 and num * yi == b - yi2:
					error = 1
					break
			elif (a - xi2) % xi == 0 and b - yi2 == 0:
				error = 1
				break
	else:
		num = 0
		if yi != 0:
			if a - xi2 == 0 and (b - yi2) % yi == 0 and ((b - yi2) // yi >= 0):
				error = 1
				break
		elif a - xi2 == 0 and b - yi2 == 0:
			error = 1
			break
if error == 1:
	print('Yes')
else:
	print('No')


X = {'R': 1, 'L': -1, 'U': 0, 'D': 0}
Y = {'R': 0, 'L': 0, 'U': 1, 'D': -1}
(a, b) = list(map(int, input().split()))
s = input()
(dx, dy) = (0, 0)
for c in s:
	dx += X[c]
	dy += Y[c]
ret = False
if a == 0 and b == 0:
	ret = True
(cx, cy) = (0, 0)
for c in s:
	cx += X[c]
	cy += Y[c]
	k = 0
	if dx != 0 and (a - cx) % dx == 0:
		k = (a - cx) // dx
	if dy != 0 and (b - cy) % dy == 0:
		k = (b - cy) // dy
	if k >= 0 and k * dx + cx == a and (k * dy + cy == b):
		ret = True
if ret:
	print('Yes')
else:
	print('No')


def inc(c, x, y):
	if c == 'R':
		x += 1
	if c == 'L':
		x -= 1
	if c == 'U':
		y += 1
	if c == 'D':
		y -= 1
	return (x, y)
(a, b) = map(int, input().split())
s = input()
(x, y) = (0, 0)
for i in range(len(s)):
	(x, y) = inc(s[i], x, y)
(nx, ny) = (0, 0)
for i in range(len(s) + 1):
	if x == 0 and y == 0 and (nx == a) and (ny == b):
		print('Yes')
		exit()
	if x == 0 and y != 0 and (nx == a) and ((b - ny) % y == 0) and ((b - ny) // y >= 0):
		print('Yes')
		exit()
	if x != 0 and y == 0 and (ny == b) and ((a - nx) % x == 0) and ((a - nx) // x >= 0):
		print('Yes')
		exit()
	if x != 0 and y != 0 and ((a - nx) % x == 0) and ((b - ny) % y == 0) and ((a - nx) // x >= 0) and ((b - ny) // y >= 0) and ((a - nx) // x == (b - ny) // y >= 0):
		print('Yes')
		exit()
	if i < len(s):
		(nx, ny) = inc(s[i], nx, ny)
print('No')


def reachable(target, position, vector):
	(x, y) = vector
	dx = target[0] - position[0]
	dy = target[1] - position[1]
	if x == y == dx == dy == 0:
		return True
	if x == 0:
		if dx != 0:
			return False
		elif y != 0:
			return dy % y == 0 and dy / y >= 0
	if y == 0:
		if dy != 0:
			return False
		elif x != 0:
			return dx % x == 0 and dx / x >= 0
	return dx / x == dy / y and dx / x >= 0 and (dx % x == 0)

def possible(target, moves, net):
	p = [0, 0]
	if reachable(target, p, net):
		return True
	for move in moves:
		if move == 'U':
			p[1] += 1
		elif move == 'D':
			p[1] -= 1
		elif move == 'R':
			p[0] += 1
		elif move == 'L':
			p[0] -= 1
		if reachable(target, p, net):
			return True
	return False
target = tuple(map(int, input().split()))
moves = input()
net = [0, 0]
for move in moves:
	if move == 'U':
		net[1] += 1
	elif move == 'D':
		net[1] -= 1
	elif move == 'R':
		net[0] += 1
	elif move == 'L':
		net[0] -= 1
if possible(target, moves, net):
	print('Yes')
else:
	print('No')


(x, y) = map(int, input().split())
s = input()
pt = (0, 0)
path = [(0, 0)]
rect = [0, 0, 1, 1]
for c in s:
	if c == 'U':
		pt = (pt[0], pt[1] + 1)
	elif c == 'D':
		pt = (pt[0], pt[1] - 1)
	elif c == 'L':
		pt = (pt[0] - 1, pt[1])
	elif c == 'R':
		pt = (pt[0] + 1, pt[1])
	if pt[0] < rect[0]:
		rect[0] = pt[0]
	if pt[0] >= rect[2]:
		rect[2] = pt[0] + 1
	if pt[1] < rect[1]:
		rect[1] = pt[1]
	if pt[1] >= rect[3]:
		rect[3] = pt[1] + 1
	path.append(pt)
done = False
if pt[0] == 0:
	if pt[1] == 0:
		if (x, y) in path:
			done = True
			print('Yes')
		else:
			print('No')
			done = True
	elif pt[1] > 0:
		n = max((y - rect[3]) // pt[1] - 2, 0)
		while n * pt[1] + rect[1] <= y:
			if (x - n * pt[0], y - n * pt[1]) in path:
				print('Yes')
				done = True
				break
			n += 1
	elif pt[1] < 0:
		n = max((y - rect[1]) // pt[1] - 2, 0)
		while n * pt[1] + rect[3] >= y:
			if (x - n * pt[0], y - n * pt[1]) in path:
				print('Yes')
				done = True
				break
			n += 1
elif pt[0] > 0:
	n = max((x - rect[2]) // pt[0] - 2, 0)
	while n * pt[0] + rect[0] <= x:
		if (x - n * pt[0], y - n * pt[1]) in path:
			print('Yes')
			done = True
			break
		n += 1
elif pt[0] < 0:
	n = max((x - rect[0]) // pt[0] - 2, 0)
	while n * pt[0] + rect[2] >= x:
		if (x - n * pt[0], y - n * pt[1]) in path:
			print('Yes')
			done = True
			break
		n += 1
if not done:
	print('No')


def main():
	(a, b) = map(int, input().split())
	(s, t) = (input(), -100)
	x = sum(({'L': -1, 'R': 1}.get(c, 0) for c in s))
	y = sum(({'D': -1, 'U': 1}.get(c, 0) for c in s))
	if x and y:
		t += min(a // x, b // y)
	elif x:
		t += a // x
	elif y:
		t += b // y
	if t > 0:
		a -= t * x
		b -= t * y
	for c in s * 101:
		if a == 0 == b:
			print('Yes')
			return
		a -= {'L': -1, 'R': 1}.get(c, 0)
		b -= {'D': -1, 'U': 1}.get(c, 0)
	print('No')
main()


def R():
	return list(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
(a, b) = R()
s = S()
l = len(s)
step = []
(x, y) = (0, 0)
d = {'U': (0, 1), 'D': (0, -1), 'L': (-1, 0), 'R': (1, 0)}
step.append((0, 0))
for i in range(l):
	(dx, dy) = d[s[i]]
	x += dx
	y += dy
	step.append((x, y))
(tx, ty) = step[l]
for j in range(l):
	(xj, yj) = step[j]
	if tx == 0 and ty == 0:
		if a == xj and b == yj:
			print('Yes')
			return
		else:
			continue
	if tx == 0 and (a != xj or (b - yj) % ty != 0 or ((b - yj) % ty == 0 and (b - yj) / ty < 0)):
		continue
	if ty == 0 and (b != yj or (a - xj) % tx != 0 or ((a - xj) % tx == 0 and (a - xj) / tx < 0)):
		continue
	if tx == 0 or ty == 0:
		print('Yes')
		return
	if (a - xj) % tx == 0 and (b - yj) % ty == 0 and ((a - xj) / tx == (b - yj) / ty >= 0):
		print('Yes')
		return
print('No')


(a, b) = map(int, input().split())
s = input()
sm = [[0, 0] for i in range(len(s))]
repl = {'U': (0, 1), 'D': (0, -1), 'L': (-1, 0), 'R': (1, 0)}
for (i, c) in enumerate(s):
	sm[i][0] = sm[i - 1][0] + repl[c][0]
	sm[i][1] = sm[i - 1][1] + repl[c][1]
for i in range(len(s)):
	(na, nb) = (0 if sm[-1][0] == 0 else (a - sm[i][0]) // sm[-1][0], 0 if sm[-1][1] == 0 else (b - sm[i][1]) // sm[-1][1])
	if a == na * sm[-1][0] + sm[i][0] and b == nb * sm[-1][1] + sm[i][1] and (0 in sm[-1] or na == nb) and (na >= -1) and (nb >= -1):
		print('Yes')
		exit(0)
print('No')


(a, b) = map(int, input().split())
if a == b == 0:
	print('Yes')
else:
	ans = 'No'
	t = input()
	(p, h) = ([0] * len(t), [0, 0])
	d = {'L': (-1, 0), 'R': (1, 0), 'D': (-1, 1), 'U': (1, 1)}
	for (i, c) in enumerate(t):
		(j, k) = d[c]
		h[k] += j
		p[i] = (h[0], h[1])
	if h[0] == h[1] == 0:
		if (a, b) in p:
			ans = 'Yes'
	elif h[0]:
		for (x, y) in p:
			if (a - x) * h[1] == (b - y) * h[0] and (a - x) % h[0] == 0 and ((a - x) * h[0] >= 0):
				ans = 'Yes'
				break
	else:
		for (x, y) in p:
			if a == x and (b - y) % h[1] == 0 and ((b - y) * h[1] >= 0):
				ans = 'Yes'
				break
	print(ans)


import logging as log

class Point(object):

	def __init__(self, x, y):
		(self.x, self.y) = (x, y)

	def __str__(self):
		return '({}, {})'.format(self.x, self.y)

	def __add__(self, other):
		return Point(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Point((other.x < self.x) & self.x - other.x, (other.y < self.y) & self.y - other.y)

	def __truediv__(self, other):
		if other.x == 0:
			return Point(0, self.y / other.y)
		elif other.y == 0:
			return Point(self.x / other.x, 0)
		else:
			return Point(self.x / other.x, self.y / other.y)

	def __mul__(self, other):
		return Point(self.x * other, self.y * other)

	def __eq__(self, other):
		return self.x == other.x and self.y == other.y

class CMDSeq(object):
	trans = {'U': Point(0, 1), 'D': Point(0, -1), 'R': Point(1, 0), 'L': Point(-1, 0)}

	def __init__(self, seq):
		self.seq = seq
		self.seq_delta = {k: 0 for k in 'LURD'}
		self.parse_cmdseq()
		self.hori_delta = self.seq_delta['R'] - self.seq_delta['L']
		self.vert_delta = self.seq_delta['U'] - self.seq_delta['D']
		self.delta = Point(self.hori_delta, self.vert_delta)
		self.max_hori_delta = max(self.seq_delta['R'], self.seq_delta['L'])
		self.max_vert_delta = max(self.seq_delta['U'], self.seq_delta['D'])
		self.loopback_factor = max(max(self.max_hori_delta - self.hori_delta, 0), max(self.max_vert_delta - self.vert_delta, 0))
		self.is_loop = self.hori_delta == self.vert_delta == 0

	def parse_cmdseq(self):
		for i in self.seq:
			self.seq_delta[i] += 1

	def repeat_ratio(self, point):
		return point / Point(self.hori_delta, self.vert_delta)

	def __str__(self):
		return '%s' % self.seq

def Robot():
	log.basicConfig(format='%(levelname)s:%(message)s', level=log.CRITICAL)
	end = Point(*[*map(int, input().split())])
	log.debug('End point: %s.', end)
	cmd = CMDSeq(input())
	log.info('Command sequence: %s.', cmd.seq)
	log.info('Command sequence delta: (%s, %s).', cmd.hori_delta, cmd.vert_delta)
	log.debug('Command max hori delta: %s.', cmd.max_hori_delta)
	log.debug('Command max vert delta: %s.', cmd.max_vert_delta)
	log.debug('Command loopback ratio: %s.', cmd.loopback_factor)
	if end == Point(0, 0):
		log.debug('!!! End point is (0,0) !!!')
		return 'Yes'
	elif cmd.is_loop:
		log.debug('Command sequence is a closed loop!')
		new_start_a = Point(0, 0)
		new_start_b = Point(0, 0)
	else:
		repeat = cmd.repeat_ratio(end)
		log.debug('Repeat point: %s', repeat)
		if repeat.x == 0:
			repeat = repeat.y
		elif repeat.y == 0:
			repeat = repeat.x
		else:
			repeat = min(repeat.x, repeat.y)
		log.debug('Repeat: %s', repeat)
		new_start_a = cmd.delta * max(int(repeat) - cmd.loopback_factor - 1, 0)
		new_start_b = cmd.delta * max(int(repeat) - cmd.loopback_factor, 0)
	log.info('New start A: %s', new_start_a)
	log.info('New start B: %s', new_start_b)
	log.debug('------\nWalking the robot:')
	for rep in range(cmd.loopback_factor + 1):
		for i in cmd.seq:
			log.debug('Current command: %s', i)
			if new_start_a == end or new_start_b == end:
				return 'Yes'
			new_start_a += CMDSeq.trans[i]
			new_start_b += CMDSeq.trans[i]
			log.debug('Modified start A: %s.', new_start_a)
			log.debug('Modified start B: %s.', new_start_b)
	return 'Yes' if new_start_a == end or new_start_b == end else 'No'
a = Robot()
print(a)


R = lambda : map(int, input().split())
(a, b) = R()
cs = [[0, 0]]
d = {'R': (1, 0), 'L': (-1, 0), 'U': (0, 1), 'D': (0, -1)}
for c in input():
	cs.append([cs[-1][0] + d[c][0], cs[-1][1] + d[c][1]])
(px, py) = (cs[-1][0], cs[-1][1])
for (x, y) in cs:
	k = 0
	if px:
		k = (a - x) // px
	elif py:
		k = (b - y) // py
	if k >= 0 and x + k * px == a and (y + k * py == b):
		print('Yes')
		return
print('No')


(a, b) = list(map(int, input().split()))
s = input()
p = [[0, 0]]
d = {'R': (1, 0), 'L': (-1, 0), 'U': (0, 1), 'D': (0, -1)}
for c in s:
	p.append([p[-1][0] + d[c][0], p[-1][1] + d[c][1]])
(px, py) = (p[-1][0], p[-1][1])
for (x, y) in p:
	k = 0
	if px:
		k = (a - x) // px
	elif py:
		k = (b - y) // py
	if k >= 0 and x + k * px == a and (y + k * py == b):
		print('Yes')
		break
else:
	print('No')


(a, b) = map(int, input().split())
s = list(input())
dist = a * a + b * b
lis = [[0, 0]]
ver = hor = 0
for i in s:
	if i == 'U':
		ver += 1
	elif i == 'D':
		ver -= 1
	elif i == 'R':
		hor += 1
	else:
		hor -= 1
	lis.append([hor, ver])
flag = 1
if [a, b] in lis:
	print('Yes')
	exit()
for i in lis:
	if [a, b] == [i[0] + lis[-1][0], i[1] + lis[-1][0]]:
		print('Yes')
		exit()
for i in range(len(lis)):
	l = 0
	r = 100000000000
	(c, d) = lis[i]
	while l <= r:
		mid = l + (r - l) // 2
		e = mid * lis[-1][0]
		f = mid * lis[-1][1]
		if (e + c) ** 2 + (f + d) ** 2 < dist:
			l = mid + 1
		else:
			r = mid - 1
	if [l * lis[-1][0] + c, l * lis[-1][1] + d] == [a, b]:
		print('Yes')
		flag = 0
		break
	elif [r * lis[-1][0] + c, r * lis[-1][1] + d] == [a, b]:
		print('Yes')
		flag = 0
		break
if flag:
	print('No')


def main():
	(a, b) = map(int, input().split())
	(steps, t) = ([((-1, 1, 0)['LR'.find(c)], (-1, 1, 0)['DU'.find(c)]) for c in input()], -25)
	x = sum((e[0] for e in steps))
	y = sum((e[1] for e in steps))
	if x and y:
		t += min(a // x, b // y)
	elif x:
		t += a // x
	elif y:
		t += b // y
	if t > 0:
		a -= t * x
		b -= t * y
	for _ in range(26):
		for (dx, dy) in steps:
			if not (a or b):
				print('Yes')
				return
			a -= dx
			b -= dy
	print('No')
main()


(a, b) = (int(x) for x in input().split())
s = input()
if (a, b) == (0, 0):
	print('Yes')
	exit()
cur = (0, 0)
poss = []
for c in s:
	poss.append(cur)
	if c == 'U':
		cur = (cur[0], cur[1] + 1)
	elif c == 'D':
		cur = (cur[0], cur[1] - 1)
	elif c == 'L':
		cur = (cur[0] - 1, cur[1])
	else:
		cur = (cur[0] + 1, cur[1])
if cur[0] == 0 and cur[1] == 0:
	print('Yes' if (a, b) in poss else 'No')
	exit()
for (x, y) in poss:
	if cur[0] != 0 and (a - x) % cur[0] != 0:
		continue
	if cur[1] != 0 and (b - y) % cur[1] != 0:
		continue
	if (a - x) * cur[0] < 0 or (b - y) * cur[1] < 0:
		continue
	if (a - x) * cur[1] == (b - y) * cur[0]:
		print('Yes')
		exit()
print('No')


go = {'U': (0, 1), 'D': (0, -1), 'R': (1, 0), 'L': (-1, 0)}
(a, b) = map(int, input().split())
s = input()
dx = dy = x = y = cx = cy = 0
for c in s:
	dx += go[c][0]
	dy += go[c][1]
ans = a == b == 0
for c in s:
	x += go[c][0]
	y += go[c][1]
	(cx, cy) = (a - x, b - y)
	flg = False
	if dx:
		flg = not cx % dx and cx // dx >= 0
	else:
		flg = not cx
	if dy:
		flg = flg and (not cy % dy) and (cy // dy >= 0)
	else:
		flg = flg and (not cy)
	flg = flg and (not dx or not dy or cx // dx == cy // dy)
	if flg:
		ans = True
		break
print('Yes' if ans else 'No')


target = tuple(map(int, input().split()))
s = input()
ok = False
pos = (0, 0)
for c in s:
	if c == 'L':
		pos = (pos[0] - 1, pos[1])
	if c == 'R':
		pos = (pos[0] + 1, pos[1])
	if c == 'U':
		pos = (pos[0], pos[1] + 1)
	if c == 'D':
		pos = (pos[0], pos[1] - 1)
	if pos == target:
		ok = True
if pos == (0, 0):
	if ok:
		print('Yes')
	else:
		print('No')
	exit()
if pos[0] == 0:
	if target[1] * pos[1] < 0:
		raport = 0
	else:
		raport = target[1] // pos[1]
elif target[0] * pos[0] < 0:
	raport = 0
else:
	raport = target[0] // pos[0]
if raport > 0:
	raport = max(0, raport - 1000)
if raport < 0:
	raport = min(0, raport + 1000)
coord = (pos[0] * raport, pos[1] * raport)
for rep in range(0, 5000):
	if coord == target:
		ok = True
	for c in s:
		if c == 'L':
			coord = (coord[0] - 1, coord[1])
		if c == 'R':
			coord = (coord[0] + 1, coord[1])
		if c == 'U':
			coord = (coord[0], coord[1] + 1)
		if c == 'D':
			coord = (coord[0], coord[1] - 1)
		if coord == target:
			ok = True
if ok:
	print('Yes')
else:
	print('No')


3
import sys
MAPPING = {'U': (0, 1), 'D': (0, -1), 'L': (-1, 0), 'R': (1, 0)}

def read_ints():
	return [int(x) for x in input().split()]

def get_vectors(moves):
	vector = (0, 0)
	yield vector
	for move in moves:
		delta = MAPPING[move]
		vector = (vector[0] + delta[0], vector[1] + delta[1])
		yield vector

def mul(pair, a):
	return (pair[0] * a, pair[1] * a)

def is_achievable(diff, period):
	if diff == (0, 0):
		return True
	if period == (0, 0):
		return False
	if period[0] != 0:
		if diff[0] % period[0] == 0:
			times = diff[0] // period[0]
			if times > 0 and mul(period, times) == diff:
				return True
	if period[1] != 0:
		if diff[1] % period[1] == 0:
			times = diff[1] // period[1]
			if times > 0 and mul(period, times) == diff:
				return True
	return False

def main():
	(a, b) = read_ints()
	moves = input().strip()
	vectors = list(get_vectors(moves))
	period = vectors[-1]
	for vector in vectors:
		diff = (a - vector[0], b - vector[1])
		if is_achievable(diff, period):
			print('Yes')
			return
	print('No')

def __starting_point():
	main()
__starting_point()


dx = 0
dy = 0
(a, b) = list(map(int, input().split()))
s = input()
for i in s:
	if i == 'U':
		dy += 1
	elif i == 'D':
		dy -= 1
	elif i == 'L':
		dx -= 1
	else:
		dx += 1
x0 = 0
y0 = 0
for i in s:
	if i == 'U':
		y0 += 1
	elif i == 'D':
		y0 -= 1
	elif i == 'L':
		x0 -= 1
	else:
		x0 += 1
	if (a - x0) * dy == (b - y0) * dx and (dx == 0 and x0 == a or (dx != 0 and (a - x0) % dx == 0 and ((a - x0) // dx >= -1))) and (dy == 0 and y0 == b or (dy != 0 and (b - y0) % dy == 0 and ((b - y0) // dy >= -1))):
		print('Yes')
		exit()
print('No')


(a, b) = map(int, input().split())
s = input().strip()
c2d = dict()
c2d['U'] = (0, 1)
c2d['D'] = (0, -1)
c2d['L'] = (-1, 0)
c2d['R'] = (1, 0)
dx = dy = 0
for c in s:
	dx += c2d[c][0]
	dy += c2d[c][1]
ans = not a and (not b)
x = 0
y = 0
for c in s:
	x += c2d[c][0]
	y += c2d[c][1]
	xx = a - x
	yy = b - y
	if (xx % dx == 0 and xx // dx >= 0 if dx else not xx) and (yy % dy == 0 and yy // dy >= 0 if dy else not yy) and (not dx or not dy or xx // dx == yy // dy):
		ans = True
print('Yes' if ans else 'No')


import sys
(ox, oy) = map(int, sys.stdin.readline().split())
s = sys.stdin.readline()
h = 0
v = 0
for i in range(len(s)):
	if s[i] == 'R':
		h += 1
	if s[i] == 'L':
		h -= 1
	if s[i] == 'U':
		v += 1
	if s[i] == 'D':
		v -= 1

def bs(l, r, a, b, rx, ry):
	l1 = l
	r1 = r
	a1 = a
	b1 = b
	while l1 <= r1:
		mid = (l1 + r1) // 2
		a1 = a + h * mid
		b1 = b + v * mid
		if rx == a1 and ry == b1:
			return 0
		if (rx - a1) * h == 0:
			if (ry - b1) * v > 0:
				l1 = mid + 1
			elif (ry - b1) * v < 0:
				r1 = mid - 1
			else:
				return -1
		if (ry - b1) * v == 0:
			if (rx - a1) * h > 0:
				l1 = mid + 1
			elif (rx - a1) * h < 0:
				r1 = mid - 1
			else:
				return -1
		if (rx - a1) * h != 0 and (ry - b1) * v != 0:
			if (rx - a1) * h > 0 and (ry - b1) * v > 0:
				l1 = mid + 1
			elif (rx - a1) * h < 0 and (ry - b1) * v < 0:
				r1 = mid - 1
			else:
				return -1
	return -1
a = 0
b = 0
pos = bs(0, 10 ** 9, a, b, ox, oy)
kt = False
if pos == 0:
	print('Yes')
	kt = True
if kt == False:
	for i in range(len(s)):
		if s[i] == 'R':
			a += 1
		if s[i] == 'L':
			a -= 1
		if s[i] == 'U':
			b += 1
		if s[i] == 'D':
			b -= 1
		pos = bs(0, 10 ** 9, a, b, ox, oy)
		if pos == 0:
			print('Yes')
			kt = True
			break
if kt == False:
	print('No')


(a, b) = input().split()
a = int(a)
b = int(b)
s = input()
n = len(s)
L = []
x = 0
y = 0
hor = s.count('R') - s.count('L')
ver = s.count('U') - s.count('D')
L = [[0, 0]]
for i in range(n):
	if s[i] == 'U':
		y += 1
	elif s[i] == 'D':
		y -= 1
	elif s[i] == 'R':
		x += 1
	else:
		x -= 1
	L.append([x, y])
k = True
for i in range(n + 1):
	x = L[i][0]
	y = L[i][1]
	if hor == 0 and ver == 0 and (x == a) and (b == y):
		print('Yes')
		k = False
		break
	elif hor == 0 and ver != 0 and (x == a) and ((b - y) % ver == 0) and ((b - y) * ver >= 0):
		print('Yes')
		k = False
		break
	elif ver == 0 and hor != 0 and (y == b) and ((a - x) % hor == 0) and ((a - x) * hor >= 0):
		print('Yes')
		k = False
		break
	elif ver != 0 and hor != 0 and ((b - y) % ver == 0) and (ver * (b - y) >= 0) and ((a - x) % hor == 0) and (hor * (a - x) >= 0) and ((b - y) // ver == (a - x) // hor):
		print('Yes')
		k = False
		break
if k:
	print('No')


d = {'U': (0, 1), 'D': (0, -1), 'R': (1, 0), 'L': (-1, 0)}
(x, y) = [int(i) for i in input().split()]
path = input()
c = {}
c[0] = (0, 0)
(dx, dy) = (0, 0)
for i in range(len(path)):
	(dx, dy) = (dx + d[path[i]][0], dy + d[path[i]][1])
	(x1, y1) = (c[i][0] + d[path[i]][0], c[i][1] + d[path[i]][1])
	c[i + 1] = (x1, y1)
if (x, y) in c.values():
	print('Yes')
else:
	for i in range(1, len(c)):
		if dy != 0 and dx != 0 and ((x - c[i][0]) / dx == (y - c[i][1]) / dy) and ((x - c[i][0]) % dx == 0) and ((y - c[i][1]) / dy >= 0):
			print('Yes')
			break
		elif dx == 0 and dy != 0:
			if (y - c[i][1]) % dy == 0 and (y - c[i][1]) / dy > 0 and (c[i][0] == x):
				print('Yes')
				break
		elif dy == 0 and dx != 0:
			if (x - c[i][0]) % dx == 0 and (x - c[i][0]) / dx > 0 and (c[i][1] == y):
				print('Yes')
				break
	else:
		print('No')


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def dif(a, b):
	if a > 0 and b < 0:
		return True
	if b > 0 and a < 0:
		return True
	return False
(a, b) = value()
s = input()
C = Counter(s)
X = C['R'] - C['L']
Y = C['U'] - C['D']
x = 0
y = 0
ans = 'No'
if (x, y) == (a, b):
	ans = 'Yes'
for i in s:
	if i == 'R':
		x += 1
	elif i == 'L':
		x -= 1
	elif i == 'U':
		y += 1
	else:
		y -= 1
	need_x = a - x
	need_y = b - y
	ok = True
	if (x, y) == (a, b):
		ans = 'Yes'
	if need_x == 0 or X == 0:
		if need_x != X:
			ok = False
		else:
			flag1 = -1
	elif dif(X, need_x) or abs(need_x) % abs(X):
		ok = False
	else:
		flag1 = abs(need_x) // abs(X)
	if need_y == 0 or Y == 0:
		if need_y != Y:
			ok = False
		else:
			flag2 = -1
	elif dif(Y, need_y) or abs(need_y) % abs(Y):
		ok = False
	else:
		flag2 = abs(need_y) // abs(Y)
	if ok and (flag2 == flag1 or flag1 == -1 or flag2 == -1):
		ans = 'Yes'
print(ans)