Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended up entangled and now have to be untangled again.

The device is powered by two wires "plus" and "minus". The wires run along the floor from the wall (on the left) to the device (on the right). Both the wall and the device have two contacts in them on the same level, into which the wires are plugged in some order. The wires are considered entangled if there are one or more places where one wire runs above the other one. For example, the picture below has four such places (top view): [Image] 

Mike knows the sequence in which the wires run above each other. Mike also noticed that on the left side, the "plus" wire is always plugged into the top contact (as seen on the picture). He would like to untangle the wires without unplugging them and without moving the device. Determine if it is possible to do that. A wire can be freely moved and stretched on the floor, but cannot be cut.

To understand the problem better please read the notes to the test samples.


-----Input-----

The single line of the input contains a sequence of characters "+" and "-" of length n (1 ≤ n ≤ 100000). The i-th (1 ≤ i ≤ n) position of the sequence contains the character "+", if on the i-th step from the wall the "plus" wire runs above the "minus" wire, and the character "-" otherwise.


-----Output-----

Print either "Yes" (without the quotes) if the wires can be untangled or "No" (without the quotes) if the wires cannot be untangled.


-----Examples-----
Input
-++-

Output
Yes

Input
+-

Output
No

Input
++

Output
Yes

Input
-

Output
No



-----Note-----

The first testcase corresponds to the picture in the statement. To untangle the wires, one can first move the "plus" wire lower, thus eliminating the two crosses in the middle, and then draw it under the "minus" wire, eliminating also the remaining two crosses.

In the second testcase the "plus" wire makes one full revolution around the "minus" wire. Thus the wires cannot be untangled:  [Image] 

In the third testcase the "plus" wire simply runs above the "minus" wire twice in sequence. The wires can be untangled by lifting "plus" and moving it higher:  [Image] 

In the fourth testcase the "minus" wire runs above the "plus" wire once. The wires cannot be untangled without moving the device itself:  [Image]

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Data structures

Implementation

Greedy algorithms


Solutions:
sequence = input().strip()
if len(sequence) % 2 != 0:
	print('No')
else:
	stack = []
	for s in sequence:
		if stack and s == stack[-1]:
			stack.pop()
		else:
			stack.append(s)
	if stack:
		print('No')
	else:
		print('Yes')


a = input().strip()
stack = []
for c in a:
	if len(stack) != 0 and stack[-1] == c:
		stack.pop()
	else:
		stack.append(c)
if len(stack) == 0:
	print('Yes')
else:
	print('No')


from sys import stdin
(lines, line_index) = (stdin.readlines(), -1)

def get_line():
	global lines, line_index
	line_index += 1
	return lines[line_index]

def main():
	string = get_line().strip()
	stack = []
	for c in string:
		if not stack:
			stack.append(c)
		elif stack[-1] == c:
			stack.pop()
		else:
			stack.append(c)
	if not stack:
		print('Yes')
	else:
		print('No')
main()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
INF = 999999999999999999999999
alphabets = 'abcdefghijklmnopqrstuvwxyz'

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

class SegTree:

	def __init__(self, n):
		self.N = 1 << n.bit_length()
		self.tree = [0] * (self.N << 1)

	def update(self, i, j, v):
		i += self.N
		j += self.N
		while i <= j:
			if i % 2 == 1:
				self.tree[i] += v
			if j % 2 == 0:
				self.tree[j] += v
			(i, j) = (i + 1 >> 1, j - 1 >> 1)

	def query(self, i):
		v = 0
		i += self.N
		while i > 0:
			v += self.tree[i]
			i >>= 1
		return v

def SieveOfEratosthenes(limit):
	isPrime = [True] * (limit + 1)
	isPrime[0] = isPrime[1] = False
	primes = []
	for i in range(2, limit + 1):
		if not isPrime[i]:
			continue
		primes += [i]
		for j in range(i * i, limit + 1, i):
			isPrime[j] = False
	return primes

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		s = rs()
		if len(s) % 2:
			ws('No')
			exit()
		q = []
		for i in s:
			q.append(i)
			while len(q) >= 2 and q[-1] == q[-2]:
				q.pop()
				q.pop()
		ws('No') if len(q) else ws('Yes')
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


from collections import deque
s = input()
n = len(s)
stack = deque()
for i in range(n):
	if not len(stack) or stack[-1] != s[i]:
		stack.append(s[i])
	else:
		stack.pop()
if len(stack):
	print('No')
else:
	print('Yes')


s = input()
stack = []
for c in s:
	if len(stack) == 0:
		stack.append(c)
	elif stack[-1] == c:
		stack.pop()
	else:
		stack.append(c)
if len(stack) == 0:
	print('Yes')
else:
	print('No')


sequence = input()
stack = []
for each in sequence:
	if len(stack) == 0:
		stack.append(each)
	elif stack[len(stack) - 1] == each:
		stack.pop()
	else:
		stack.append(each)
if len(stack) == 0:
	print('Yes')
else:
	print('No')


s = input()
if len(s) % 2:
	print('No')
	exit(0)
if s[::2].count('+') - s[1::2].count('+') == 0:
	print('Yes')
	exit(0)
print('No')


str = input().strip()
stack = []
i = 1
size = len(str)
stack.append(str[0])
while i < size:
	stack.append(str[i])
	if len(stack) > 1 and stack[-1] == stack[-2]:
		stack.pop()
		stack.pop()
	i += 1
ans = False
if len(stack) == 0:
	ans = True
elif len(stack) == 2:
	if stack[0] == stack[1]:
		ans = True
if ans:
	print('Yes')
else:
	print('No')


s = input()
ss = []
for i in range(len(s)):
	if s[i] == '+':
		if ss != [] and ss[-1] == 1:
			ss.pop()
		else:
			ss.append(1)
	elif ss != [] and ss[-1] == 0:
		ss.pop()
	else:
		ss.append(0)
if not len(ss):
	print('Yes')
	exit(0)
loc = 1
for i in range(1, len(ss)):
	if ss[i] == ss[i - 1]:
		loc ^= 1
	elif loc == 1:
		break
	else:
		loc = 1
if loc == 1:
	print('No')
else:
	print('Yes')


st = input()
st = list(st)
st1 = []
cc = 0
for i in range(len(st)):
	if len(st1) > 0:
		if st1[-1] == st[i]:
			st1.pop()
		else:
			st1.append(st[i])
	else:
		st1.append(st[i])
if len(st1) == 0:
	print('Yes')
else:
	print('No')


s = input()
if len(s) % 2 == 1:
	print('No')
else:
	x = len(s) - 1
	start = 1
	while len(s) != x:
		x = len(s)
		n = x
		for i in range(max(start, 1), x):
			l = i - 1
			r = i
			if s[l] == s[r]:
				while l >= 0 and r < n and (s[l] == s[r]):
					r += 1
					l -= 1
				l += 1
				r -= 1
				s = s[:l] + s[r + 1:]
				start = l
				break
	if len(s) == 0:
		print('Yes')
	else:
		print('No')


s = input()
stack = []
for i in s:
	if not stack:
		stack.append(i)
		continue
	f = 0
	while stack:
		if stack[-1] == i:
			f = 1
			stack.pop()
		else:
			break
	if not f:
		stack.append(i)
if stack:
	print('No')
else:
	print('Yes')


import sys
line = sys.stdin.readline().strip()
if len(line) % 2 == 1:
	print('No')
else:
	stack = []
	stack.append(line[0])
	for i in range(1, len(line)):
		if len(stack) > 0:
			if line[i] == stack[-1]:
				del stack[-1]
			else:
				stack.append(line[i])
		else:
			stack.append(line[i])
	if len(stack) > 0:
		print('No')
	else:
		print('Yes')


st = input()
arr = list(st)
dp = [arr[0]]
for i in arr[1:]:
	if len(dp) == 0:
		dp.append(i)
	elif i == dp[-1]:
		dp.pop()
	else:
		dp.append(i)
if len(dp):
	print('No')
else:
	print('Yes')


class squeue:

	def __init__(self):
		self._data = []

	def push(self, e):
		self._data.append(e)

	def empty(self):
		if len(self._data) == 0:
			return True
		else:
			return False

	def pop(self):
		self._data.pop(-1)

	def top(self):
		if self.empty() == True:
			return False
		else:
			return self._data[-1]

	def len(self):
		return len(self._data)
inp = input()
a = squeue()
for i in range(len(inp)):
	if inp[i] != a.top():
		a.push(inp[i])
	else:
		a.pop()
if a.empty():
	print('Yes')
else:
	print('No')


a = input()
s = []
if len(a) == 1:
	print('No')
else:
	f = 0
	for i in range(len(a)):
		if len(s) == 0:
			s.append(a[i])
		elif a[i] == s[len(s) - 1]:
			s.pop()
		else:
			s.append(a[i])
	if len(s) == 0:
		print('yes')
	else:
		print('No')


X = input()
L = []
for i in X:
	if L == []:
		L.append(str(i))
	elif i == L[len(L) - 1]:
		L.pop()
	else:
		L.append(i)
if L == []:
	print('Yes')
else:
	print('No')


n = input()
t = len(n)
s = 0
if t % 2 != 0:
	print('No')
	exit()
else:
	for i in range(0, t, 2):
		if n[i] == '+':
			s += 1
	for i in range(1, t + 1, 2):
		if n[i] == '+':
			s -= 1
	if s == 0:
		print('Yes')
	else:
		print('No')


class ArrayStack:

	def __init__(self):
		self._data = []

	def __len__(self):
		return len(self._data)

	def is_empty(self):
		return len(self._data) == 0

	def push(self, e):
		self._data.append(e)

	def top(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data[-1]

	def pop(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data.pop()
l = input()
n = len(l)
p = ArrayStack()
p.__init__()
for i in range(0, n):
	if p.is_empty():
		p.push(l[i])
	elif l[i] == p.top():
		p.pop()
	else:
		p.push(l[i])
if p.is_empty():
	print('Yes')
else:
	print('No')


class ArrayStack:

	def __init__(self):
		self._data = []

	def __len__(self):
		return len(self._data)

	def is_empty(self):
		return len(self._data) == 0

	def push(self, e):
		self._data.append(e)

	def top(self):
		if self.is_empty():
			raise Exception('Stack is empty')
		return self._data[-1]

	def pop(self):
		if self.is_empty():
			raise Exception('Stack is empty')
		return self._data.pop()

def is_untangled(expr):
	S = ArrayStack()
	for c in expr:
		if S.is_empty():
			S.push(c)
		elif S.top() != c:
			S.push(c)
		else:
			S.pop()
	return S.is_empty()
str = input()
if is_untangled(str):
	print('Yes')
else:
	print('No')


s = input()
c = 0
t = 0
for i in s:
	if t % 2 == 0:
		if i == '+':
			c += 1
		else:
			c -= 1
	elif i == '-':
		c += 1
	else:
		c -= 1
	t += 1
if c == 0:
	print('Yes')
else:
	print('No')


(W, st) = (list(input()), [])
for i in W:
	if len(st) and st[-1] == i:
		st.pop()
	else:
		st.append(i)
print('No') if len(st) else print('Yes')


initial = list(input())
stringStatus = []
for i in range(len(initial)):
	stringStatus.append(initial[i])
	if len(stringStatus) >= 2:
		if stringStatus[-1] == stringStatus[-2]:
			stringStatus.pop()
			stringStatus.pop()
if len(stringStatus) == 0:
	print('yes')
else:
	print('no')


import sys
import math
st = input()
mystack = [st[0]]
for i in range(1, len(st)):
	if mystack != []:
		v = mystack.pop()
		if v != st[i]:
			mystack.append(v)
			mystack.append(st[i])
	else:
		mystack.append(st[i])
if mystack == []:
	print('Yes')
else:
	print('No')


s = input()
l = len(s)
i = 0
stack = list()
while i < l:
	if len(stack) == 0:
		stack.append(s[i])
		i = i + 1
	else:
		t = stack[-1]
		if t == s[i]:
			stack.pop()
		else:
			stack.append(s[i])
		i = i + 1
if len(stack) == 0:
	print('Yes')
else:
	print('No')


seq = input()
stack = []
for elem in seq:
	stack.append(elem)
	while len(stack) > 1 and stack[-1] == stack[-2]:
		stack.pop()
		stack.pop()
if not stack:
	print('Yes')
else:
	print('No')


a = input()
x = 0
y = 0
for i in range(len(a)):
	if i % 2 != 0:
		if a[i] == '-':
			y += 1
		else:
			x += 1
	elif a[i] == '-':
		x += 1
	else:
		y += 1
if x == y:
	print('YES')
else:
	print('NO')


s = input()
ss = []
for i in s:
	if len(ss) > 0 and ss[-1] == i:
		ss.pop()
	else:
		ss.append(i)
if len(ss) == 0:
	print('Yes')
else:
	print('No')


s = input()
stack = []
for i in s:
	if stack and i == stack[-1]:
		stack.pop()
	else:
		stack.append(i)
if stack:
	print('No')
else:
	print('Yes')


class Empty(Exception):
	pass

class ArrayStack:

	def __init__(self):
		self._data = []

	def __len__(self):
		return len(self._data)

	def is_empty(self):
		return len(self._data) == 0

	def push(self, e):
		self._data.append(e)

	def top(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data[-1]

	def pop(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data.pop()

	def show(self):
		print(self._data)
s = ArrayStack()
x = input()
for c in x:
	if s.is_empty() == True:
		s.push(c)
	elif c == s.top():
		s.pop()
	else:
		s.push(c)
if s.is_empty() == True:
	print('Yes')
else:
	print('No')


wire = input()
stack = ['null']
if len(wire) % 2 != 0:
	print('No')
	exit()
for i in wire:
	if stack[-1] == i:
		stack.pop()
	else:
		stack.append(i)
if len(stack) > 1:
	print('No')
else:
	print('Yes')


cables = input()
cola = []
for signo in cables:
	if cola:
		if signo == cola[-1]:
			cola.pop(-1)
		else:
			cola.append(signo)
	else:
		cola.append(signo)
if cola:
	print('No')
else:
	print('Yes')


class Stack:

	def __init__(self):
		self.items = []

	def isEmpty(self):
		return self.items == []

	def push(self, item):
		self.items.append(item)

	def pop(self):
		return self.items.pop()

	def peek(self):
		return self.items[len(self.items) - 1]

	def size(self):
		return len(self.items)

def untangle(sequence):
	s = Stack()
	for i in sequence:
		if not s.isEmpty():
			if i == s.peek():
				s.pop()
			else:
				s.push(i)
		else:
			s.push(i)
	if not s.isEmpty():
		print('No')
	else:
		print('Yes')
quence = input()
untangle(quence)


x = input()
s = 0
for i in range(len(x)):
	if (i % 2 == 0) ^ (x[i] == '+'):
		s += 1
	else:
		s -= 1
if s == 0:
	print('Yes')
else:
	print('No')


a = input()
s = []
for i in a:
	if s == []:
		s.append(i)
	elif i != s[-1]:
		s.append(i)
	else:
		s.pop()
if s == []:
	print('Yes')
else:
	print('No')


class ArrayStack:

	def __init__(self):
		self._data = []

	def __len__(self):
		return len(self._data)

	def is_empty(self):
		return len(self._data) == 0

	def push(self, e):
		self._data.append(e)

	def top(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data[-1]

	def pop(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data.pop()

class Empty(Exception):
	pass
a = input()
b = ArrayStack()
c = len(a)
if c % 2 != 0:
	print('No')
else:
	for i in range(c):
		if b.is_empty():
			b.push(a[i])
		elif b.top() == a[i]:
			b.pop()
		elif b.top != a[i]:
			b.push(a[i])
	if b.is_empty():
		print('Yes')
	else:
		print('No')


import sys

def solve(zap):
	n = len(zap)
	if n % 2 != 0:
		print('No')
		return
	homtop = 0
	for i in range(0, n, 2):
		c = zap[i] + zap[i + 1]
		if c == '+-':
			homtop += 1
		elif c == '-+':
			homtop -= 1
	print('Yes' if homtop == 0 else 'No')
zap = sys.stdin.readline().strip()
solve(zap)


stack = []
for i in input():
	if len(stack) > 0:
		if stack[-1] == i:
			stack.pop()
		else:
			stack.append(i)
	else:
		stack.append(i)
if len(stack) > 0:
	print('No')
else:
	print('Yes')


list_inp = input()
stack_jud = []
for i in list_inp:
	if len(stack_jud) > 0:
		if stack_jud[-1] == i:
			stack_jud.pop()
		else:
			stack_jud.append(i)
	else:
		stack_jud.append(i)
if stack_jud == []:
	print('Yes')
else:
	print('No')


stack = ['#']
for c in input():
	if stack[-1] == c:
		stack.pop()
	else:
		stack.append(c)
stack.pop()
print('No' if len(stack) else 'Yes')


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
s = input()
st = ['1']
for i in s:
	if st[-1] == i:
		st.pop()
	else:
		st.append(i)
if len(st) == 1:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
from collections import defaultdict, Counter
import math
I = stdin.readline
s = I().rstrip()
arr = [s[0]]
for i in range(1, len(s)):
	if arr and s[i] == arr[-1]:
		arr.pop()
	else:
		arr.append(s[i])
if arr:
	print('No')
else:
	print('Yes')


s = input()
l = [s[0]]
len1 = len(s)
i = 1
flag = 0
while i < len1:
	p = l.pop()
	if p != s[i]:
		l.append(p)
		l.append(s[i])
		i += 1
	else:
		i += 1
		if len1 == i and len(l) == 0:
			flag = 1
			print('Yes')
		elif len(l) == 0:
			l.append(s[i])
			i += 1
if flag == 0:
	try:
		l.pop()
		print('No')
	except:
		print('Yes')


s = input()
stack = []
for i in range(0, len(s)):
	if len(stack) == 0:
		stack.append(s[i])
	elif s[i] == stack[-1]:
		stack.pop()
	else:
		stack.append(s[i])
if len(stack) == 0:
	print('Yes')
else:
	print('No')


ans = []
for c in input():
	if len(ans) and ans[-1] == c:
		ans.pop()
	else:
		ans += [c]
print('No' if len(ans) else 'Yes')


s = input()
stack = []
for i in s:
	if stack and i == stack[-1]:
		stack.pop()
	else:
		stack.append(i)
if stack == []:
	print('YES')
else:
	print('NO')


s = input()
p = 0
n = 0
for i in range(len(s)):
	if i % 2 == 0:
		if s[i] == '-':
			p += 1
		else:
			n += 1
	elif s[i] == '-':
		n += 1
	else:
		p += 1
if p == n:
	print('Yes')
else:
	print('No')


n = input()
stack = [n[0]]
i = 1
while i < len(n):
	if len(stack) and n[i] == stack[len(stack) - 1]:
		stack.pop(len(stack) - 1)
	else:
		stack.append(n[i])
	i += 1
if len(stack) == 0:
	print('YES')
else:
	print('NO')


class ArrayStack:

	def __init__(self):
		self._data = []

	def __len__(self):
		return len(self._data)

	def is_empty(self):
		return len(self._data) == 0

	def push(self, e):
		self._data.append(e)

	def top(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data[-1]

	def pop(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data.pop()
wire = input()
NodeNumber = len(wire)
Nodes = ArrayStack()
Nodes.push(wire[0])
if NodeNumber % 2 != 0:
	print('No')
else:
	for i in range(1, NodeNumber):
		if Nodes.is_empty():
			Nodes.push(wire[i])
		else:
			tem = Nodes.pop()
			if wire[i] != tem:
				Nodes.push(tem)
				Nodes.push(wire[i])
	if Nodes.is_empty():
		print('Yes')
	else:
		print('No')


wire = list(input())
stack = [wire[0]]
for i in range(1, len(wire)):
	if len(stack) > 0 and wire[i] == stack[len(stack) - 1]:
		stack.pop()
	else:
		stack.append(wire[i])
if len(stack) == 0:
	print('Yes')
else:
	print('No')


i = input()
s = []
for k in i:
	l = len(s)
	if l == 0:
		s += k
	elif k == s[l - 1]:
		del s[l - 1]
	else:
		s += k
l = len(s)
if l == 0:
	print('Yes')
else:
	print('No')


st = []
s = input().strip()
for i in s:
	if len(st) and st[-1] == i:
		st.pop()
	else:
		st.append(i)
if len(st):
	print('NO')
else:
	print('YES')


class ArrayStack:

	def __init__(self):
		self._data = []

	def __len__(self):
		return len(self._data)

	def is_empty(self):
		return len(self._data) == 0

	def push(self, e):
		self._data.append(e)

	def top(self):
		return self._data[-1]

	def pop(self):
		return self._data.pop()
S = ArrayStack()
s = input()
boolean = 0
if len(s) % 2 == 1:
	print('No')
	boolean = 1
else:
	for c in s:
		if len(S) > 0:
			a = S.pop()
			if not a == c:
				S.push(a)
				S.push(c)
		else:
			S.push(c)
if len(S) == 2:
	print('No')
	boolean = 1
if len(S) > 2:
	print('No')
	boolean = 1
if boolean == 0:
	print('Yes')


s = input().strip()
stack = []
for k in range(len(s)):
	if not stack or s[k] != stack[-1]:
		stack.append(s[k])
	elif s[k] == stack[-1]:
		stack.pop()
if not stack:
	print('Yes')
else:
	print('No')


wire = list(input())
stack = []

def untangle(a, b):
	if a == b:
		return True
	else:
		return False
for x in wire:
	if stack == []:
		stack.append(x)
	elif untangle(x, stack[-1]):
		stack.pop(-1)
	else:
		stack.append(x)
if stack == []:
	print('Yes')
else:
	print('No')


string = input()
t = []
for char in string:
	if not t:
		t.append(char)
		continue
	if t[-1] == char:
		t.pop()
	else:
		t.append(char)
if t:
	print('No')
else:
	print('Yes')


inp = input().strip()
stack = list()
i = 0
while i < len(inp):
	if len(stack) != 0 and stack[-1] == inp[i]:
		stack.pop()
	else:
		stack.append(inp[i])
	i = i + 1
if len(stack) == 0:
	print('Yes')
else:
	print('No')


wires = input()
c = 0
d = 0
for i in range(len(wires)):
	if wires[i] == '+':
		c += 2 * (i % 2) - 1
	if wires[i] == '-':
		d += 2 * (i % 2) - 1
if c == 0 and d == 0:
	print('Yes')
else:
	print('No')


n = input()
l = []
for i in n:
	if len(l) and i == l[-1]:
		del l[-1]
	else:
		l.append(i)
print('Yes' if l == [] else 'No')


seq = list(input())
if len(seq) % 2 == 1:
	print('No')
else:
	a = 0
	b = 0
	for i in range(len(seq) // 2):
		if seq[2 * i] == '+':
			a += 1
		elif seq[2 * i] == '-':
			b += 1
		if seq[2 * i + 1] == '+':
			b += 1
		elif seq[2 * i + 1] == '-':
			a += 1
	if a == b:
		print('Yes')
	else:
		print('No')


s = input()
if len(s) % 2 != 0:
	print('No')
else:
	list = list(s)
	t = 0
	list1 = []
	while t < len(s):
		if list[t] is '+' and list[t + 1] is '-':
			list1.append(1)
		if list[t] is '-' and list[t + 1] is '+':
			list1.append(-1)
		t = t + 2
	if sum(list1) == 0:
		print('Yes')
	else:
		print('No')


stack = []
soc = input()
flag = True
if len(soc) % 2 == 0:
	for sign in soc:
		if stack != [] and stack[-1] == sign:
			stack.pop()
		else:
			stack.append(sign)
		if len(stack) > len(soc) / 2:
			break
else:
	flag = False
if flag and stack == []:
	print('Yes')
else:
	print('No')


scheme = input().strip()
leftDivedCount = 0
rightDivedCount = 0
for (i, c) in enumerate(scheme):
	leftWire = '-' if i % 2 == 1 else '+'
	if leftWire == c:
		rightDivedCount += 1
	else:
		leftDivedCount += 1
print('Yes' if rightDivedCount == leftDivedCount else 'No')


s = input()
st = []
for i in s:
	if st:
		if st[-1] == i:
			st.pop()
		else:
			st.append(i)
	else:
		st.append(i)
if st:
	print('No')
else:
	print('Yes')


s = input()
a = []
for i in s:
	if len(a) > 0:
		if a[-1] != i:
			a.append(i)
		else:
			a.pop(-1)
	else:
		a.append(i)
if len(a) > 0:
	print('No')
else:
	print('Yes')


def desenrredar(cable):
	pasos = len(cable)
	if pasos % 2 == 1:
		return pasos
	if '++' in cable:
		cable = cable.replace('++', '')
	if '--' in cable:
		cable = cable.replace('--', '')
	cable = list(cable)
	pos = -1
	while pos <= len(cable):
		pos += 1
		if len(cable) == 0:
			break
		if pos + 1 < len(cable) and pos >= 0:
			if cable[pos] == cable[pos + 1]:
				cable.pop(pos)
				cable.pop(pos)
				pos -= 2
		if pos - 1 >= 0 and pos < len(cable):
			if cable[pos] == cable[pos - 1]:
				cable.pop(pos)
				cable.pop(pos - 1)
				pos -= 2
	return len(cable)
cables = input()
if desenrredar(cables) == 0:
	print('Yes')
else:
	print('No')


s = input()
arr = []
arr.append(s[0])
s = s[1:]
for i in s:
	if arr and arr[-1] == i:
		arr.pop()
	else:
		arr.append(i)
if arr:
	print('No')
else:
	print('Yes')


s = input()
n = len(s)
ans = []
ans.append([s[0], 1])
for i in range(1, n):
	if len(ans) == 0:
		ans.append([s[i], 1])
	elif ans[-1][0] == s[i]:
		ans[-1][1] += 1
	else:
		if ans[-1][1] % 2 == 0:
			ans.pop()
		if len(ans) == 0 or ans[-1][0] != s[i]:
			ans.append([s[i], 1])
		else:
			ans[-1][1] += 1
if len(ans) > 0 and ans[-1][1] % 2 == 0:
	ans.pop()
if len(ans):
	print('No')
else:
	print('Yes')


from collections import deque
a = input().rstrip()
q = deque()
for i in a:
	if len(q) > 0 and i == q[-1]:
		q.pop()
	else:
		q.append(i)
print('Yes' if len(q) == 0 else 'No')


def main():
	stack = []
	for c in input():
		if stack and c == stack[-1]:
			del stack[-1]
		else:
			stack.append(c)
	print(('Yes', 'No')[bool(stack)])

def __starting_point():
	main()
__starting_point()


s = input()
st = []
for i in range(0, len(s)):
	if len(st) == 0 or s[i] != st[-1]:
		st.append(s[i])
	else:
		st.pop()
if st:
	print('no')
else:
	print('yes')


import inspect

class Input:

	@classmethod
	def array_integer(cls):
		return MyList(map(int, input().split()))

	@classmethod
	def array_string(cls):
		return input().split()

	@classmethod
	def integer(cls):
		return int(input())

	@classmethod
	def float(cls):
		return float(input())

	@classmethod
	def string(cls):
		return input()

class Number:
	max = float('inf')
	min = -float('inf')

	@classmethod
	def is_digit(cls, character):
		return character in '0123456789'

class This:

	def __init__(self):
		self.max = self.min = self.sum = self.count = None
		self.set = set()
		self.map = dict()
		self.reset()

	def update_if_max(self, value):
		self.max = max(self.max, value)

	def update_if_min(self, value):
		self.min = min(self.min, value)

	def reset(self):
		self.min = Number.max
		self.max = Number.min
		self.sum = 0
		self.count = 0

class MyList(list):

	@property
	def length(self):
		return len(self)

	@property
	def is_empty(self):
		return not self

	@property
	def first(self):
		return self[0]

	@property
	def last(self):
		return self[-1]

	@property
	def is_sorted(self, key=lambda x: x):
		for i in range(len(self) - 1):
			if key(self[i]) > key(self[i + 1]):
				return False
		return True

	def push(self, element):
		return self.append(element)

	def for_each(self, callback):
		if not callable(callback):
			raise ValueError(f'Expected a function, got {callback} instead.')
		arg_count = len(inspect.getfullargspec(callback).args)
		for (i, item) in enumerate(self):
			arguments = []
			if arg_count >= 1:
				arguments.append(item)
			if arg_count >= 2:
				arguments.append(i)
			callback(*arguments)

	def map(self, callback):
		if not callable(callback):
			raise ValueError(f'Expected a function, got {callback} instead.')
		return MyList(map(callback, self))

	@classmethod
	def of(cls, size, value):
		if not isinstance(size, list):
			raise ValueError('Expected size to be a list of dimensions.')
		if len(size) == 0:
			raise ValueError('Size cannot be empty.')
		invalid_sizes_type = list(filter(lambda x: not isinstance(x, int), size))
		if len(invalid_sizes_type) > 0:
			raise ValueError('Sizes should be integers.')
		invalid_sizes_value = list(filter(lambda x: x <= 0, size))
		if len(invalid_sizes_value) > 0:
			raise ValueError('Sizes should be positive.')
		return MyList._of(size[::-1], value)

	@classmethod
	def _of(cls, size, value):
		if len(size) == 1:
			try:
				return MyList((value() for _ in range(size[0])))
			except TypeError:
				return MyList((value for _ in range(size[0])))
		else:
			count = size.pop()
			return MyList((MyList._of(size[:], value) for _ in range(count)))

	def copy(self):
		return MyList(list.copy(self))

	def __add__(self, other):
		return MyList(list.__add__(self, other))

	def __mul__(self, other):
		return MyList(list.__mul__(self, other))

class String(str):

	@property
	def length(self):
		return len(self)

	@property
	def is_empty(self):
		return not self

	@property
	def first(self):
		return self[0]

	@property
	def last(self):
		return self[-1]

	@property
	def is_sorted(self, key=lambda x: x):
		for i in range(len(self) - 1):
			if key(self[i]) > key(self[i + 1]):
				return False
		return True
	_alphabets = 'abcdefghijklmnopqrstuvwxyz'

	@classmethod
	def is_alphabet(cls, ch):
		return ch in String._alphabets

def solve():
	string = Input.string()
	string = MyList(string)
	stack = MyList()
	for ch in string:
		if stack.is_empty:
			stack.push(ch)
		elif ch == stack.last:
			stack.pop()
		else:
			stack.push(ch)
	if stack.is_empty:
		print('Yes')
	else:
		print('No')
solve()


s = input()
st = []
st.append(s[0])
j = 1
for i in s[1:]:
	if j >= 1 and st[j - 1] == i:
		st.pop()
		j -= 1
	else:
		j += 1
		st.append(i)
if len(st) == 0:
	print('Yes')
else:
	print('No')


s = input()
st = []
for x in s:
	if not st or st[-1] != x:
		st.append(x)
	else:
		st.pop()
if st:
	print('No')
else:
	print('Yes')


a = input()
top = a[0]
ln = 1

def neg(c):
	if c == '+':
		return '-'
	if c == '-':
		return '+'
for i in a[1:]:
	if ln == 0:
		top = i
		ln += 1
	elif i == top:
		ln -= 1
		top = neg(i)
	else:
		top = i
		ln += 1
if ln == 0:
	print('Yes')
else:
	print('No')


x = input()
s = []
count = 0
while count < len(x):
	if len(s) != 0 and x[count] == s[-1]:
		s.pop()
		count += 1
		continue
	s.append(x[count])
	count += 1
if s == []:
	print('Yes')
else:
	print('No')


a = input()
b = []
for i in range(len(a)):
	if b == []:
		b.append(a[i])
		continue
	if b[-1] == a[i]:
		b.pop()
	else:
		b.append(a[i])
if len(b) == 0:
	print('Yes')
else:
	print('No')


s = []
for i in input():
	if s and s[-1] == i:
		s.pop()
	else:
		s.append(i)
print('Yneos'[bool(s)::2])


import sys
from math import *
from random import *

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
s = input()
t = []
for i in s:
	if len(t) == 0:
		t.append(i)
	elif t[-1] != i:
		t.append(i)
	else:
		t.pop()
if len(t):
	print('No')
else:
	print('Yes')


import random, math, sys
input = sys.stdin.readline

def solution(s):
	stack = []
	s = s[::-1]
	for i in s:
		if stack and stack[-1] == i:
			stack.pop()
		else:
			stack.append(i)
	return not bool(len(stack))

def input_test():
	s = input().strip()
	out = solution(s)
	print('YES' if out else 'NO')
input_test()


from sys import stdin
s = stdin.readline().rstrip()
l = []
for i in range(len(s)):
	if len(l) != 0:
		if l[len(l) - 1] == s[i]:
			l.pop(len(l) - 1)
		else:
			l.append(s[i])
	else:
		l.append(s[i])
if len(l) == 0:
	print('Yes')
else:
	print('No')


s = input()
st = [s[0]]
for sign in s[1:]:
	if len(st) != 0 and sign == st[-1]:
		st.pop()
	else:
		st.append(sign)
if len(st) == 0:
	print('Yes')
else:
	print('No')


s = input().strip()
a = ['K']
for i in s:
	if a[-1] == i:
		a.pop()
	else:
		a.append(i)
if len(a) == 1:
	print('Yes')
else:
	print('No')


s = input()
l = list(s)
stack = []
stack.append(l[0])
for i in range(1, len(l)):
	if len(stack) is not 0:
		if l[i] == stack[len(stack) - 1]:
			stack.pop()
		else:
			stack.append(l[i])
	else:
		stack.append(l[i])
if len(stack) == 0:
	print('Yes')
else:
	print('No')


str = input()
stack = []
for i in str:
	try:
		if stack[-1] == i:
			stack.pop()
		else:
			stack.append(i)
	except:
		stack.append(i)
if len(stack) == 0:
	print('Yes')
else:
	print('No')


class ArrayStack:

	def __init__(self):
		self._data = []

	def __len__(self):
		return len(self._data)

	def is_empty(self):
		return len(self._data) == 0

	def push(self, e):
		self._data.append(e)

	def top(self):
		return self._data[-1]

	def pop(self):
		return self._data.pop()
S = ArrayStack()
A = input()
A = list(A)
l = len(A)
S.push(A[0])
for i in range(1, l):
	if S.is_empty():
		S.push(A[i])
	else:
		a = S.pop()
		if A[i] == a:
			pass
		else:
			S.push(a)
			S.push(A[i])
if S.is_empty():
	print('Yes')
else:
	print('No')


from sys import stdin, stdout

def fin():
	return stdin.readline().strip()

def fout(x):
	stdout.write(str(x) + '\n')
stk = []
for i in fin():
	if stk and stk[-1] == i:
		stk.pop()
	else:
		stk.append(i)
if not stk:
	fout('Yes')
else:
	print('No')


class Empty(Exception):
	pass

class ArrayStack:

	def __init__(self):
		self._data = []

	def __len__(self):
		return len(self._data)

	def is_empty(self):
		return len(self._data) == 0

	def push(self, NewElement):
		self._data.append(NewElement)

	def top(self):
		if self.is_empty():
			raise Empty('Stack is empty.')
		return self._data[-1]

	def pop(self):
		if self.is_empty():
			raise Empty('Stack is empty.')
		return self._data.pop()
s = input()
a = ArrayStack()
if len(s) == 0:
	print('Yes')
elif len(s) == 1:
	print('No')
else:
	for i in s:
		if len(a) == 0:
			a.push(i)
		elif a.top() == i:
			a.pop()
		else:
			a.push(i)
	if len(a) == 0:
		print('Yes')
	else:
		print('No')


x = input()
l = len(x)
if l % 2 == 1:
	print('No')
else:
	s = 0
	for i in range(0, int(l / 2)):
		s += ord(x[2 * i]) - ord(x[2 * i + 1])
	if s == 0:
		print('Yes')
	else:
		print('No')


import sys
x = input()
if len(x) == 1:
	print('No')
	sys.exit(0)
else:
	st = []
	a = 1
	st.append(x[0])
	for i in range(1, len(x)):
		e = x[i]
		if a == 0:
			st.append(e)
			a += 1
		elif e == st[-1]:
			st.pop()
			if len(st) == 0:
				a = 0
			else:
				a = 1
		else:
			st.append(e)
			a = 1
if a % 2 == 0:
	print('Yes')
else:
	print('No')


sequence = [char for char in input().strip()]
stack = []
for char in sequence:
	if len(stack) == 0:
		stack.append(char)
	elif char == stack[-1]:
		stack.pop()
	else:
		stack.append(char)
print('Yes' if len(stack) == 0 else 'No')


(s, l) = (input(), [])
for i in s:
	if l == []:
		l.append(i)
	elif i == l[-1]:
		del l[-1]
	else:
		l.append(i)
if l == []:
	print('Yes')
else:
	print('No')


c = []
a = list(input())
for i in a:
	if not c:
		c.append(i)
	elif i == c[-1]:
		c.pop()
	else:
		c.append(i)
if c:
	print('No')
else:
	print('Yes')


import sys

def input():
	return sys.stdin.readline().strip()
stri = input()
S = []
for i in stri:
	if len(S) == 0:
		S.append(i)
	elif i == '+' and S[-1] == '+':
		S.pop()
	elif i == '-' and S[-1] == '-':
		S.pop()
	else:
		S.append(i)
print('Yes') if len(S) == 0 else print('No')


s = input()
st = []
for i in range(0, len(s)):
	if len(st) == 0 or st[-1] != s[i]:
		st.append(s[i])
	else:
		st.pop()
if st:
	print('NO')
else:
	print('YES')


n = input()
a = []
for i in range(len(n)):
	a.append(n[i])
	if len(a) > 1 and a[-1] == a[-2]:
		a.pop()
		a.pop()
if len(a) == 0:
	print('Yes')
else:
	print('No')


s = []
for c in input():
	if s and c == s[-1]:
		s.pop()
	else:
		s.append(c)
if s:
	print('No')
else:
	print('Yes')


s = []
for i in input():
	if s and s[-1] == i:
		s.pop()
	else:
		s.append(i)
print('Yneos'[len(s) > 0::2])


class stack:

	def __init__(self):
		self._data = []

	def pop(self):
		return self._data.pop()

	def top(self):
		return self._data[-1]

	def push(self, i):
		self._data.append(i)

	def __len__(self):
		return len(self._data)

	def __repr__(self):
		return ', '.join((str(i) for i in self._data))
s = input()
a = stack()
for i in range(len(s)):
	if len(a) == 0:
		a.push(s[i])
	elif a.top() != s[i]:
		a.push(s[i])
	else:
		a.pop()
if len(a) != 0:
	print('No')
else:
	print('Yes')


intp = [i for i in input()]
stack = ['_']
if len(intp) % 2:
	print('No')
else:
	for i in intp:
		if i == stack[-1]:
			stack.pop()
		else:
			stack.append(i)
	print('Yes' if len(stack) == 1 else 'No')


s = input()
x = [0]
c = 0
i = 0
while i < len(s):
	j = i
	while j < len(s) and s[j] == s[i]:
		j += 1
	if j - i & 1:
		if x[-1] != s[i]:
			x.append(s[i])
		else:
			x.pop(-1)
	i = j
if x[-1] == 0:
	print('Yes')
else:
	print('No')


def Untangled(exp):
	stack = []
	for i in exp:
		if not stack or stack[-1] != i:
			stack.append(i)
		else:
			stack.pop()
	return 'No' if stack else 'Yes'
exp = input().strip()
print(Untangled(exp))


s = input()
(a, b) = ([], [])
(x, y) = (0, 0)
while x < len(s):
	while x < len(s) - 1 and s[x] == s[x + 1]:
		x = x + 2
	if x < len(s):
		a.append(s[x])
		x = x + 1
while y < len(a):
	if len(b) != 0 and b[-1] != a[y] or len(b) == 0:
		b.append(a[y])
		y = y + 1
	else:
		b.pop()
		y = y + 1
if len(b) == 0:
	print('Yes')
else:
	print('No')


s = input()
(j, k) = ([], [])
(i, t) = (0, 0)
while i < len(s):
	while i < len(s) - 1 and s[i] == s[i + 1]:
		i = i + 2
	if i < len(s):
		j.append(s[i])
		i = i + 1
while t < len(j):
	if len(k) != 0 and k[-1] != j[t] or len(k) == 0:
		k.append(j[t])
		t = t + 1
	else:
		k.pop()
		t = t + 1
if len(k) == 0:
	print('Yes')
else:
	print('No')


def entangle(a):
	s = list(a)
	c = list()
	if len(s) == 1:
		return 'No'
	else:
		c.append(s[0])
	i = 1
	while i < len(s):
		if len(c) > 0:
			if s[i] == c[len(c) - 1]:
				c.pop()
			else:
				c.append(s[i])
		else:
			c.append(s[i])
		i = i + 1
	if len(c) == 0:
		return 'Yes'
	else:
		return 'No'
s0 = input()
print(entangle(s0))


arr = []
strs = input()
for i in strs:
	if len(arr) == 0:
		arr.append(i)
		continue
	if arr[-1] == i:
		arr.pop()
	else:
		arr.append(i)
if len(arr) > 0:
	print('NO')
else:
	print('YES')


string = input()
stack = []
for i in string:
	flag = True
	while stack:
		if stack[-1] == i:
			stack.pop()
			flag = False
		else:
			break
	if flag:
		stack += (i,)
if len(stack) == 0:
	print('Yes')
else:
	print('No')


a = input()
stack = []
for i in a:
	if not stack:
		stack.append(i)
	elif stack and stack[-1] == i:
		stack.pop()
	else:
		stack.append(i)
if stack:
	print('No')
else:
	print('Yes')


str = input()
stack = []
for ch in str:
	if stack and stack[-1] == ch:
		stack.pop()
	else:
		stack.append(ch)
if stack:
	print('No')
else:
	print('Yes')


s = input().strip()
st = ['!']
for si in s:
	if st[-1] == si:
		st.pop()
	else:
		st.append(si)
print('Yes' if len(st) == 1 else 'No')


S = list(input())
charge = []
top = -1
no_of_notes = 0
for i in S:
	c = i
	if top == -1:
		charge.append(c)
		top += 1
		no_of_notes += 1
	elif c == charge[top]:
		no_of_notes -= 1
		charge.pop()
		top -= 1
	else:
		no_of_notes += 1
		charge.append(c)
		top += 1
if top == -1:
	print('Yes')
else:
	print('No')


s = input()
ls = len(s)
k = [None] * ls
for i in range(ls):
	if i % 2 == 0:
		k[i] = 1 if s[i] == '-' else 0
	else:
		k[i] = 0 if s[i] == '-' else 1
stack = []
i = 0
while i < ls:
	if stack:
		if k[i] != stack[-1]:
			stack.pop()
		else:
			stack.append(k[i])
	else:
		stack.append(k[i])
	i += 1
print('No' if stack else 'Yes')


sp = list(input())
spisok = []
for i in sp:
	if not spisok:
		spisok.append(i)
	elif i != spisok[-1]:
		spisok.append(i)
	else:
		spisok.pop()
if spisok:
	print('No')
else:
	print('Yes')


l = list(input())
li = []
li.append(l[0])
for i in range(1, len(l)):
	if len(li) != 0 and l[i] == li[-1]:
		li.pop()
	else:
		li.append(l[i])
if len(li) != 0 or len(l) == 1:
	print('No')
else:
	print('Yes')


from collections import deque
wire = input()
l = len(wire)
s = []
top = 0
for c in wire:
	s.append(c)
	top += 1
	while top >= 2 and s[-1] == s[-2]:
		s.pop()
		s.pop()
		top -= 2
if top == 0:
	print('Yes')
else:
	print('No')


s = list(input())
stack = []
for x in s:
	if stack != [] and stack[-1] == x:
		del stack[-1]
	else:
		stack.append(x)
if stack == []:
	print('YES')
else:
	print('NO')


from collections import Counter, defaultdict, deque
import heapq as hq
from itertools import count, islice
import math
import sys
input = sys.stdin.readline
s = input().strip('\n')
stack = deque()
for i in range(len(s)):
	stack.append(s[i])
	while len(stack) >= 2 and stack[-1] == stack[-2]:
		stack.pop()
		stack.pop()
if len(stack) == 0:
	print('Yes')
else:
	print('No')


l = list(input())
if len(l) % 2 != 0:
	print('No')
else:
	stack = []
	for i in l:
		if stack:
			if stack[-1] == i:
				stack.pop()
			else:
				stack.append(i)
		else:
			stack.append(i)
	if stack:
		print('No')
	else:
		print('Yes')


__author__ = 'Utena'
import collections
s = input()
if len(s) % 2 == 1:
	print('No')
	exit(0)
t1 = t2 = 0
for i in range(len(s)):
	if s[i] == '-':
		if i % 2 == 0:
			t1 += 1
		else:
			t2 += 1
if t1 == t2:
	print('Yes')
else:
	print('No')


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
s = input().strip()
st = []
for el in s:
	if st and st[-1] == el:
		st.pop()
		continue
	st.append(el)
print('Yes' if not st else 'No')


from collections import deque
q = deque([])
n = input()
q.append(n[0])
for i in n[1:]:
	if len(q) == 0:
		q.append(i)
	elif i == q[-1]:
		q.pop()
	else:
		q.append(i)
if len(q) == 0:
	print('Yes')
else:
	print('No')


wires = list(input())
mp = '+-'
pm = '-+'
h = 0
b = 0
if len(wires) % 2 != 0:
	print('No')
	exit()
for i in range(0, len(wires), 2):
	l = wires[i] + wires[i + 1]
	if l == mp:
		h += 1
	elif l == pm:
		b += 1
if h == b:
	print('Yes')
else:
	print('No')


class Stack:

	def __init__(self, size=100):
		self.stack = []
		self.size = size
		self.top = -1

	def setSize(self, size):
		self.size = size

	def isEmpty(self):
		if self.top == -1:
			return True
		else:
			return False

	def isFull(self):
		if self.top + 1 == self.size:
			return True
		else:
			return False

	def Top(self):
		if self.isEmpty():
			raise Exception('StackIsEmpty')
		else:
			return self.stack[self.top]

	def push(self, obj):
		if self.isFull():
			raise Exception('StackOverFlow')
		else:
			self.stack.append(obj)
			self.top += 1

	def pop(self):
		if self.isEmpty():
			raise Exception('StackIsEmpty')
		else:
			self.top -= 1
			return self.stack.pop()

	def show(self):
		print(self.stack)
list = []
line = input()
for char in line:
	list.append(char)
s = Stack(len(list))
for i in range(0, len(list), 1):
	if s.isEmpty():
		s.push(list[i])
	elif s.Top() == list[i]:
		s.pop()
	else:
		s.push(list[i])
if s.isEmpty():
	print('Yes')
else:
	print('No')


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	ab = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			ab = ab * x % p
		y = y >> 1
		x = x * x % p
	return ab

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return [int(x) for x in input().split()]
s = list(input())
a = []
for i in s:
	if len(a) == 0:
		a.append(i)
	elif i == a[-1]:
		a.pop(-1)
	else:
		a.append(i)
if len(a) == 0:
	print('Yes')
else:
	print('No')


class Stack:

	def __init__(self):
		self.items = []

	def isEmpty(self):
		return len(self.items) == 0

	def push(self, item):
		self.items.append(item)

	def pop(self):
		return self.items.pop()

	def peek(self):
		if not self.isEmpty():
			return self.items[len(self.items) - 1]

	def size(self):
		return len(self.items)
x = input()
num = len(x)
t = x[0]
stack = Stack()
stack.push(x[0])
i = 1
while i < num:
	if stack.isEmpty():
		stack.push(x[i])
		t = x[i]
	elif x[i] == t:
		stack.pop()
		t = stack.peek()
	else:
		stack.push(x[i])
		t = x[i]
	i = i + 1
if stack.isEmpty():
	print('yes')
else:
	print('no')


l = []
for c in input():
	if len(l) > 0 and l[-1] == c:
		l.pop()
	else:
		l.append(c)
print('Yes' if len(l) == 0 else 'No')


current = input()
st = []
for i in current:
	if not st:
		st.append(i)
	elif st[-1] == i:
		st.pop()
	else:
		st.append(i)
if not st:
	print('Yes')
else:
	print('No')


a = input()
if len(a) % 2 == 1:
	print('No')
else:
	pm = 0
	mp = 0
	for i in range(len(a))[::2]:
		t = a[i] + a[i + 1]
		if t == '+-':
			pm += 1
		if t == '-+':
			mp += 1
	if pm == mp:
		print('Yes')
	else:
		print('No')


input = input()
stack = []
for wire in input:
	if len(stack) == 0 or wire != stack[-1]:
		stack.append(wire)
	else:
		stack.pop()
print('YES' if len(stack) == 0 else 'NO')


import sys
import collections

def solve():
	vals = list(input())
	q = collections.deque()
	for cur in vals:
		if len(q) > 0 and q[0] == cur:
			q.popleft()
		else:
			q.appendleft(cur)
	if len(q) == 0:
		return 'Yes'
	return 'No'

def read(mode=2):
	inputs = input().strip()
	if mode == 0:
		return inputs
	if mode == 1:
		return inputs.split()
	if mode == 2:
		return list(map(int, inputs.split()))

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, list):
		s = ' '.join(map(str, s))
	if isinstance(s, tuple):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='')

def run():
	res = solve()
	write(res)
run()


secuencia = input()
plus = secuencia.count('+')
minus = secuencia.count('-')
if len(secuencia) % 2 == 0:
	if secuencia == secuencia[::-1]:
		print('Yes')
	elif plus % 2 == 0 and minus % 2 == 0:
		largo = len(secuencia) // 2
		if '++' in secuencia or '--' in secuencia:
			for i in range(0, largo):
				try:
					secuencia = secuencia.replace('++', '')
					secuencia = secuencia.replace('--', '')
					continue
				except:
					continue
			if secuencia == '':
				print('Yes')
			else:
				print('No')
		else:
			print('No')
	else:
		print('No')
else:
	print('No')


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	if y == 0:
		return 1
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal

def solve():
	wire = string()
	st = []
	for x in wire:
		if len(st) == 0:
			st.append(x)
			continue
		if st[-1] == x:
			st.pop()
		else:
			st.append(x)
	if len(st) == 0:
		print('Yes')
	else:
		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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = 1
for i in range(t):
	solve()


import collections as col
import math, string
from functools import reduce
from random import randint

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	S = getStr()
	N = len(S)
	queue = []
	for i in range(N):
		if not queue or queue[-1] != S[i]:
			queue.append(S[i])
		else:
			queue.pop()
	return 'No' if queue else 'Yes'
print(solve())


s = input()
stack = 100000 * [0]
stack[0] = s[0]
top = 0
if len(s) > 1:
	for c in s[1:]:
		if top >= 0 and stack[top] == c:
			top = top - 1
		else:
			top = top + 1
			stack[top] = c
	if top >= 0:
		print('No')
	else:
		print('Yes')
else:
	print('No')


(p, j) = ([0] * 50001, 0)
for i in input():
	if i == p[j]:
		j -= 1
	else:
		j += 1
		if j > 50000:
			break
		p[j] = i
print('YNEOS'[j > 0::2])


def untangle(joints):
	tangled = []
	for joint in joints:
		if len(tangled) == 0 or tangled[-1] != joint:
			tangled.append(joint)
		else:
			tangled.pop()
	return len(tangled) == 0
joints = input()
if untangle(joints):
	print('Yes')
else:
	print('No')


lista = input()
contp = contm = 0
ult = 'x'
for i in lista:
	if i == '-':
		contm += 1
		if i == ult:
			contm -= 2
			ult = '+'
		else:
			ult = '-'
	if i == '+':
		contp += 1
		if i == ult:
			contp -= 2
			ult = '-'
		else:
			ult = '+'
if contp == 0 and contm == 0:
	print('Yes')
else:
	print('No')


str = input()
s = []
for c in str:
	if len(s) > 0 and c == s[-1]:
		del s[-1]
	else:
		s.append(c)
if len(s) > 0:
	print('NO')
else:
	print('YES')


a = []
for ch in input():
	if a and a[-1] == ch:
		a.pop()
	else:
		a.append(ch)
print('Yes' if not a else 'No')


s = input()
q = []
q.append(s[0])
for i in s[1:]:
	if len(q) == 0:
		q.append(i)
	elif q[-1] == i:
		q.pop()
	else:
		q.append(i)
if len(q) == 0:
	print('Yes')
else:
	print('No')


inp = input()
L = []
for i in inp:
	if len(L) == 0 or L[-1] != i:
		L.append(i)
	else:
		t = L.pop(-1)
if len(L) == 0:
	print('Yes')
else:
	print('No')


def abc(x, l):
	if len(l) == 0:
		l.append(x)
	elif l[-1] == x:
		l.pop(-1)
	else:
		l.append(x)
s = input()
l = len(s)
newlist = []
for i in range(l):
	if s[i] == '+':
		abc(1, newlist)
	else:
		abc(0, newlist)
if len(newlist) == 0:
	print('Yes')
else:
	print('No')


s = input()
stack = [' '] * 100000
i = 0
p = -1
while i < len(s):
	if p != -1 and stack[p] == s[i]:
		p -= 1
		i += 1
	else:
		p += 1
		stack[p] = s[i]
		i += 1
if p == -1:
	print('Yes')
else:
	print('No')


s = input()
l = len(s)
Acount = Bcount = 0
for i in range(l):
	if i + 1 & 1:
		if s[i] == '-':
			Bcount += 1
		else:
			Acount += 1
	elif s[i] == '-':
		Acount += 1
	else:
		Bcount += 1
print('Yes' if Acount == Bcount else 'No')


s = input()
q = []
n = 0
for c in s:
	if not q:
		q.append(c)
		n += 1
	elif c == q[n - 1]:
		q.pop()
		n -= 1
	else:
		q.append(c)
		n += 1
if n:
	print('No')
else:
	print('Yes')


str = input()
if len(str) % 2 != 0:
	print('No')
	exit()
stack = ['0']
for c in str:
	if c == stack[-1]:
		stack.pop()
	else:
		stack.append(c)
if len(stack) == 1:
	print('Yes')
else:
	print('No')


from sys import stdin
input = stdin.readline
s = input().rstrip()
n = len(s)
l = []
for i in range(n):
	l.append(s[i])
	if len(l) >= 2 and l[-1] == l[-2]:
		l.pop()
		l.pop()
if len(l) == 0:
	print('Yes')
else:
	print('No')


from sys import stdin
inp = stdin.readline
s = inp()[:-1]
stack = []
for i in s:
	if len(stack) and stack[-1] == i:
		stack.pop()
	else:
		stack.append(i)
print('No' if len(stack) else 'Yes')


wire = input()
l = len(wire)
s = []
top = 0
for c in wire:
	s.append(c)
	top += 1
	while top >= 2 and s[-1] == s[-2]:
		s.pop()
		s.pop()
		top -= 2
if top == 0:
	print('Yes')
else:
	print('No')


ac = list(input())
stack = []
for each in ac:
	stack.append(each)
	while len(stack) >= 2 and stack[-1] == stack[-2]:
		stack.pop()
		stack.pop()
if len(stack) == 0:
	print('Yes')
else:
	print('No')


RI = lambda : [int(x) for x in input().split()]
rw = lambda : [input().strip()]
s = list(input().strip())
stack = []
index_stack = -1
for i in s:
	if i == '+':
		if index_stack != -1:
			if stack[index_stack] == '+':
				stack.pop()
				index_stack -= 1
			else:
				stack.append(i)
				index_stack += 1
		else:
			stack.append(i)
			index_stack += 1
	if i == '-':
		if index_stack != -1:
			if stack[index_stack] == '-':
				stack.pop()
				index_stack -= 1
			else:
				stack.append(i)
				index_stack += 1
		else:
			stack.append(i)
			index_stack += 1
if index_stack == -1:
	ans = 'Yes'
else:
	ans = 'No'
print(ans)


a = list(input())
n = len(a)
s = list()
for i in range(n):
	if not s or s[-1] != a[i]:
		s.append(a[i])
	else:
		s.pop(-1)
print('No' if s else 'Yes')


def stackcheck(v):
	stack = []
	stack.append(v[0])
	for i in range(1, len(v)):
		if len(stack) == 0:
			stack.append(v[i])
			continue
		temp = stack.pop()
		if v[i] == temp:
			continue
		else:
			stack.append(temp)
			stack.append(v[i])
	return 'YES' if len(stack) == 0 else 'NO'

def main():
	v = input()
	print(stackcheck(v))
main()


n = str(input())
m = [1]
if len(n) == 1 and n == '-':
	print('No')
elif len(n) == 1 and n == '+':
	print('No')
else:
	for i in n:
		if i == '+' and i != m[-1]:
			m.append('+')
		elif i == '-' and i != m[-1]:
			m.append(i)
		elif m[len(m) - 1] == i:
			m.pop()
	if len(m) == 1:
		print('Yes')
	else:
		print('No')


a = list(input())
for i in range(len(a)):
	if i % 2 == 0:
		if a[i] == '+':
			a[i] = 'B'
		elif a[i] == '-':
			a[i] = 'A'
	elif i % 2 != 0:
		if a[i] == '+':
			a[i] = 'A'
		elif a[i] == '-':
			a[i] = 'B'
if a.count('A') == a.count('B'):
	print('YES')
else:
	print('NO')


s = input()
ans = [0] * len(s)
n = 0
for x in s:
	if n and ans[n - 1] == x:
		n -= 1
	else:
		ans[n] = x
		n += 1
print('No' if n else 'Yes')


a = input()
if len(a) % 2 == 1:
	print('No')
else:
	l = []
	for i in a:
		if l == []:
			l.append(i)
		elif i != l[-1]:
			l.append(i)
		else:
			l.pop()
	if l == []:
		print('Yes')
	else:
		print('No')


withFile = 0
if withFile == 1:
	fin = open('input.txt', 'r')
	fout = open('output.txt', 'w')

def getl():
	if withFile == 0:
		return input()
	else:
		return fin.readline()

def printl(s):
	if withFile == 0:
		print(s)
	else:
		fout.write(str(s))

def get_arr():
	x = getl().split(' ')
	if x[-1] == '':
		x = x[:-1]
	return list(map(int, x))
s = getl()
ans = []
for c in s:
	if len(ans) != 0 and ans[-1] == c:
		ans.pop()
	else:
		ans.append(c)
if len(ans) == 0:
	printl('YES')
else:
	printl('NO')
if withFile == 1:
	fin.close()
	fout.close()


import math
line = str(input())
if len(line) % 2 == 1:
	print('No')
else:
	l = len(line)
	a = []
	for i in line:
		a.append(i)
	status = 0
	if line[l - 1] == '-':
		status -= 1
	else:
		status += 1
	l -= 1
	while l > 0:
		if status % 2 == 1:
			if a[l - 1] == '+':
				status -= 1
			else:
				status += 1
		elif a[l - 1] == '-':
			status -= 1
		else:
			status += 1
		l -= 1
	if status == 0:
		print('Yes')
	else:
		print('No')


from collections import deque
c = input()
flag = True
k = -1
cc = deque('')
for i in range(len(c)):
	if c[i] == '-':
		l = 1
	else:
		l = 2
	if l == k:
		cc.pop()
		if len(cc) != 0:
			k = cc.pop()
			cc.append(k)
		else:
			k = 0
	else:
		cc.append(l)
		k = l
if len(cc) == 0:
	print('Yes')
else:
	print('No')


a = list(input())
l = len(a)
b = list()
for i in range(l):
	b.append(a[i])
	if len(b) < 2:
		continue
	elif b[-1] == b[-2]:
		b.pop()
		b.pop()
if b == []:
	print('Yes')
else:
	print('No')


def possi(s):
	if len(s) % 2 == 1:
		return 'No'
	stack = []
	stack.append(s[0])
	for i in range(1, len(s)):
		if s[i] == '+' and stack and (stack[-1] == '+'):
			stack.pop()
		elif s[i] == '-' and stack and (stack[-1] == '-'):
			stack.pop()
		else:
			stack.append(s[i])
	if len(stack) != 0:
		return 'No'
	return 'Yes'
s = input()
print(possi(s))


class ArrayStack:

	def __init__(self):
		self._data = []

	def __len__(self):
		return len(self._data)

	def is_empty(self):
		return len(self._data) == 0

	def push(self, e):
		self._data.append(e)

	def top(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data[-1]

	def pop(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data.pop()
s = tuple(input())
data = ArrayStack()
n = len(s)
k = 0
if n % 2 == 1:
	print('No')
else:
	for i in range(n):
		if len(data) == 0 or s[i] != data.top():
			data.push(s[i])
		else:
			data.pop()
	if len(data) == 0:
		print('Yes')
	else:
		print('No')


str = input()
s = []
for c in str:
	if len(s) > 0 and c == s[-1]:
		del s[-1]
	else:
		s.append(c)
if len(s) > 0:
	print('No')
else:
	print('Yes')


class current:

	def __init__(self):
		self.top = -1
		self.stk = []

	def push(self, x):
		self.top += 1
		self.stk.append(x)

	def isempty(self):
		if self.top == -1:
			return True
		else:
			return False

	def peek(self):
		if not self.isempty():
			return self.stk[len(self.stk) - 1]
		else:
			return False

	def pop(self):
		if not self.isempty():
			self.top -= 1
			return self.stk.pop()
		else:
			False

	def untangle(self, strng):
		for i in strng:
			if self.isempty():
				self.push(i)
			elif self.peek() == i:
				self.pop()
			else:
				self.push(i)
		if self.isempty():
			print('Yes')
		else:
			print('No')
n = input()
obj = current()
obj.untangle(n)


(p, j) = ([0] * 100001, 0)
for i in input():
	if i == p[j]:
		j -= 1
	else:
		j += 1
		p[j] = i
print('YNEOS'[j > 0::2])


string = input()
new = []
for i in range(len(string)):
	if new == []:
		new.append(string[i])
	elif new == []:
		new.append(string[i])
	elif new[-1] == string[i]:
		new.pop()
	else:
		new.append(string[i])
if new == []:
	print('Yes')
else:
	print('No')


s = input()
stk = []
for char in s:
	if not stk:
		stk.append(char)
		continue
	elif stk[-1] == char:
		stk.pop()
	else:
		stk.append(char)
if stk:
	print('No')
else:
	print('Yes')


l = list(input())
new = ''
idx = 0
if len(l) % 2 != 0:
	print('No')
else:
	for i in range(len(l)):
		if i % 2 != 0:
			if l[i] == '+':
				l[i] = 'A'
			else:
				l[i] = 'B'
		elif l[i] == '+':
			l[i] = 'B'
		else:
			l[i] = 'A'
	stack = []
	for i in l:
		if stack:
			if stack[-1] != i:
				stack.pop()
			else:
				stack.append(i)
		else:
			stack.append(i)
	if stack:
		print('No')
	else:
		print('Yes')


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()]
s = input()
stack = []
i = 0
n = len(s)
while i < n:
	key = s[i]
	i += 1
	c = 1
	while i < n and s[i] == key:
		i += 1
		c += 1
	c %= 2
	if not c:
		continue
	if len(stack) and stack[-1] == key:
		stack.pop()
	else:
		stack.append(key)
if not len(stack):
	print('YES')
else:
	print('NO')


from collections import Counter, deque
from sys import stdin, stdout
x = list(input())
stack = deque()
for i in range(len(x)):
	if len(stack) > 0:
		if stack[-1] == x[i]:
			stack.pop()
		else:
			stack.append(x[i])
	else:
		stack.append(x[i])
if len(stack) == 0:
	print('Yes')
else:
	print('No')


wire_sequence = input()
stack = []
for x in wire_sequence:
	if stack and stack[-1] == x:
		stack.pop()
	else:
		stack.append(x)
if stack:
	print('No')
else:
	print('Yes')


a = input()
if len(a) % 2 == 1:
	print('No')
else:
	odd = 0
	even = 0
	for i in range(len(a)):
		if a[i] == '-':
			if i % 2 == 0:
				even += 1
			else:
				odd += 1
	if even == odd:
		print('Yes')
	else:
		print('No')


n = list(input())
if len(n) % 2 != 0:
	print('No')
else:
	jj = []
	for i in range(len(n)):
		jj.append(n[i])
		if len(jj) >= 2:
			if jj[-1] == jj[-2]:
				del jj[-2:]
	if len(jj) == 0:
		print('Yes')
	else:
		print('No')


(l, pre) = ([], '')
for i in input():
	if i == pre:
		l.pop()
	else:
		l.append(i)
	if len(l) > 0:
		pre = l[len(l) - 1]
	else:
		pre = ''
print('Yes' if not l else 'No')


import math
s = list(input())
n = len(s)
stack = []
for i in range(n):
	if len(stack) > 1:
		if stack[len(stack) - 1] == stack[len(stack) - 2]:
			stack.pop()
			stack.pop()
		stack.append(s[i])
	else:
		stack.append(s[i])
if len(stack) > 1:
	if stack[len(stack) - 1] == stack[len(stack) - 2]:
		stack.pop()
		stack.pop()
if len(stack) == 0:
	print('YES')
else:
	print('NO')


string = list(input())
stack = list()
match = [('+', '+'), ('-', '-')]
for i in string:
	if stack and (stack[-1], i) in match:
		stack.pop()
	else:
		stack.append(i)
if stack == []:
	print('yes')
else:
	print('no')


class Stack:

	def __init__(self):
		self.items = []

	def isEmpty(self):
		return self.items == []

	def push(self, item):
		self.items.append(item)

	def pop(self):
		self.items.pop()

	def peek(self):
		return self.items[len(self.items) - 1]

	def size(self):
		return len(self.items)

	def printStack(self):
		return self.items
s = input()
stack = Stack()
i = 0
while i < len(s):
	if stack.isEmpty() == True:
		stack.push(s[i])
		i += 1
		continue
	while i < len(s) and stack.isEmpty() == False and (stack.peek() == s[i]):
		stack.pop()
		i += 1
	if i < len(s):
		stack.push(s[i])
		i += 1
ans = ''.join(stack.printStack())
if len(ans) == 0:
	print('Yes')
else:
	print('No')


string = input()
lst = ['0']
for i in string:
	if lst[-1] == i:
		lst.pop()
	else:
		lst.append(i)
if len(lst) == 1:
	print('Yes')
else:
	print('No')


l = input()
l = list(l)
p = []
for i in l:
	if len(p) == 0:
		p.append(i)
	elif p[-1] == i:
		p.pop()
	else:
		p.append(i)
if len(p) == 0:
	print('Yes')
else:
	print('No')


s = input()
(f, a) = ([s[0]], 0)
for i in range(1, len(s)):
	if len(f) != 0 and f[-1] == s[i]:
		a = f.pop()
	else:
		f.append(s[i])
print('Yes' if len(f) == 0 else 'No')


words = input()
wire = []
for i in words:
	if len(wire) == 0:
		wire.append(i)
	elif i == wire[-1]:
		wire.pop()
	else:
		wire.append(i)
if len(wire) == 0:
	print('Yes')
else:
	print('No')


s = str(input())
a = []
if len(s) % 2 != 0:
	print('No')
else:
	for i in range(len(s)):
		if len(a) == 0 or s[i] != str(a[-1]):
			a.append(s[i])
		else:
			a.pop()
	if len(a) == 0:
		print('Yes')
	else:
		print('No')


s = input()
if len(s) % 2:
	print('No')
	return
if s[::2].count('+') - s[1::2].count('+') == 0:
	print('Yes')
	return
print('No')


class Stack:

	def __init__(self):
		self._data = []

	def __len__(self):
		return len(self._data)

	def is_empty(self):
		return len(self._data) == 0

	def push(self, a):
		self._data.append(a)

	def top(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data[-1]

	def pop(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data.pop()
l = str(input())
s = Stack()
for i in l:
	if s.is_empty():
		s.push(i)
	elif s.top() == i:
		s.pop()
	else:
		s.push(i)
if s.is_empty():
	print('Yes')
else:
	print('No')


s = input().strip()
x = []
for i in range(len(s)):
	if not x or x[-1] != s[i]:
		x.append(s[i])
	else:
		x.pop()
if len(x) == 0:
	print('Yes')
else:
	print('No')


s = input()
stk = []
for ch in s:
	if len(stk) > 0 and stk[-1] == ch:
		stk.pop()
	else:
		stk.append(ch)
if len(stk) == 0:
	print('Yes')
else:
	print('No')


plus = minus = 0
c = 1
for i in input():
	if c % 2 != 0:
		if i == '-':
			minus += 1
		else:
			plus += 1
	elif i == '-':
		plus += 1
	else:
		minus += 1
	c += 1
print(['No', 'Yes'][plus == minus])


s = input()
st = list()
for i in s:
	if st and st[-1] == i:
		st.pop()
	else:
		st.append(i)
if not st:
	print('Yes')
else:
	print('No')


class ArrayStack:

	def __init__(self):
		self._data = []

	def __len__(self):
		return len(self._data)

	def is_empty(self):
		return len(self._data) == 0

	def push(self, e):
		self._data.append(e)

	def top(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data[-1]

	def pop(self):
		if self.is_empty():
			raise Empty('Stack is empty')
		return self._data.pop()

def is_matched(expr):
	wire = []
	for i in expr:
		if len(wire) == 0:
			wire.append(i)
		elif i == wire[-1]:
			wire.pop()
		else:
			wire.append(i)
	if len(wire) == 0:
		print('Yes')
	else:
		print('No')
word = input()
is_matched(word)


x = input()
stk1 = []
for i in x:
	if stk1 == []:
		stk1.append(i)
	elif stk1[-1] == i:
		stk1.pop()
	else:
		stk1.append(i)
if stk1 == []:
	print('Yes')
else:
	print('No')


s = input()
if len(s) % 2 != 0:
	print('No')
else:
	st = []
	for i in s:
		if st == []:
			st.append(i)
		elif i == st[-1]:
			st.pop()
		else:
			st.append(i)
	if st == []:
		print('Yes')
	else:
		print('No')