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>

Difficulty: MEDIUM_HARD
Tags: Data structures

Implementation

Greedy algorithms
Skill types: Data structures

Greedy algorithms

Starter code:

Solutions:
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)


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')


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')


s = input()
a = []
for i in s:
	if len(a) > 0:
		if a[-1] == i:
			a.pop()
		else:
			a.append(i)
	else:
		a.append(i)
if len(a) > 0:
	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')


(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')


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')


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')


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')


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')


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')


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')


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')


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')


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')


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')


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')


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')


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')


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')


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')


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


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


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)


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')


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')


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')


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')


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 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')


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


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


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')


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)


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')


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')


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


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')


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')


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))


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')


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')


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')


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')


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')


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')


__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')


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')


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')


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')


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()


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 = 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 = 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')


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')


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()
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')


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')


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')


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')