s = str(input())
sum1 = 0
sum2 = 0
for i in range(0, 7, 2):
sum1 += int(s[i])
for i in range(1, 7, 2):
sum2 += int(s[i])
if sum1 == sum2:
print("YES")
else:
print("NO")
s = str(input())
sum1 = 0
sum2 = 0
for i in range(0, 7, 2):
sum1 += int(s[i])
for i in range(1, 7, 2):
sum2 += int(s[i])
if sum1 == sum2:
print("YES")
else:
print("NO")