program madition(input,output);
var
la,lb,ll:longint;
a,b:array[1..200]of longint;
n:longint;
i,k:longint;
s1,s2:string;
begin
assign(input,'madition.in');
reset(input);
readln(n);
readln(s1);
readln(s2);
close(input);
la:=length(s1);
lb:=length(s2);
for i:=1 to la do
begin
if ('0'<=s1[la-i+1])and(s1[la-i+1]<='9') then
a[i]:=ord(s1[la-i+1])-ord('0');
if ('a'<=s1[la-i+1])and(s1[la-i+1]<='z') then
a[i]:=ord(s1[la-i+1])-ord('a')+10;
end;
for i:=1 to lb do
begin
if ('0'<=s2[lb-i+1])and(s2[lb-i+1]<='9') then
b[i]:=ord(s2[lb-i+1])-ord('0');
if ('a'<=s2[lb-i+1])and(s2[lb-i+1]<='z') then
b[i]:=ord(s2[lb-i+1])-ord('a')+10;
end;
if la>lb then ll:=la else ll:=lb;
k:=0;
for i:=1 to ll do
begin
a[i]:=a[i]+b[i]+k;
k:=a[i] div n;
a[i]:=a[i] mod n;
end;
la:=ll;
if k>0 then
begin
a[ll+1]:=k;
la:=ll+1;
end;
assign(output,'madition.out');
rewrite(output);
for i:=la downto 1 do
begin
if (a[i]>=0)and(a[i]<=9) then write(a[i])
else if (a[i]>=10) then write(chr(a[i]-10+ord('a')));
end;
close(output);
end.