Var
a,sum1,sum2,i:longint;
begin
Readln(a);
for i:= 1 to 3 do
begin
sum1 := sum1 + a mod 10;
a:= a div 10;
end;
for i:= 1 to 3 do
begin
sum2 := sum2 + a mod 10;
a:= a div 10;
end;
if (sum1 = sum2) then Writeln('YES')
else Writeln('NO');
end.
Пример:
123321
YES