function MaxDigit(n: integer): integer;
var max: integer;
begin
max := 0;
while n > 0 do
begin
if n mod 10 > max then max := n mod 10;
n := n div 10;
end;
MaxDigit := max;
end;
var a, b: integer;
begin
read(a, b);
write(MaxDigit(a) + MaxDigit(b));
end.