program madition(input,output);
type
spn=array[0..200]of byte;
var
n,i:integer;
a,b,t:spn;
ch:char;
procedure add(const a,b:spn; var c:spn);
var
i,en,h:byte;
begin
if a[0]>b[0] then
en:=a[0]
else
en:=b[0];
h:=0;
for i:=1 to en do
begin
c[i]:=a[i]+b[i]+h;
if c[i]>=n then
begin
c[i]:=c[i]-n;
h:=1;
end
else
h:=0;
end;
if h=1 then
begin
c[en+1]:=1;
c[0]:=en+1;
end
else
c[0]:=en;
end;
begin
assign(input,'madition.in');
reset(input);
assign(output,'madition.out');
rewrite(output);
readln(n);
read(ch);
t[0]:=0;
while ch>='0' do
begin
inc(t[0]);
if ch in['0'..'9'] then
t[t[0]]:=ord(ch)-ord('0')
else
t[t[0]]:=ord(ch)-ord('a')+10;
read(ch);
end;
readln;
a[0]:=t[0];
for i:=1 to t[0] do
a[i]:=t[t[0]-i+1];
read(ch);
t[0]:=0;
while ch>='0' do
begin
inc(t[0]);
if ch in['0'..'9'] then
t[t[0]]:=ord(ch)-ord('0')
else
t[t[0]]:=ord(ch)-ord('a')+10;
read(ch);
end;
b[0]:=t[0];
for i:=1 to t[0] do
b[i]:=t[t[0]-i+1];
add(a,b,t);
for i:=t[0] downto 1 do
if t[i]<10 then
write(t[i])
else
write(chr(t[i]-10+ord('a')));
writeln;
close(input);
close(output);
end.