a = input()
a1 = []
for i in range(len(a)):
a1.append(a[i])
if int(a1[0]) + int(a1[1]) + int(a1[2]) == int(a1[3]) + int(a1[4]) + int(a1[5]):
print('YES')
else:
print('NO')
a = input()
a1 = []
for i in range(len(a)):
a1.append(a[i])
if int(a1[0]) + int(a1[1]) + int(a1[2]) == int(a1[3]) + int(a1[4]) + int(a1[5]):
print('YES')
else:
print('NO')