program madition;
var
c,c1,c2,code,i,j,n:integer;
s1,s2:string;
sum,a,b:array [1..200] of integer;
begin
assign (input,'madition.in');
reset (input);
readln (n);
readln (s1);
readln (s2);
close (input);
assign (output,'madition.out');
rewrite (output);
for i:=length(s1) downto 1 do begin
j:=length(s1)-i+1;
if s1[i] in ['0'..'9'] then val(s1[i],a[j],code) else a[j]:=ord(s1[i])-87;
end;
c1:=length(s1);
for i:=length(s2) downto 1 do begin
j:=length(s2)-i+1;
if s2[i] in ['0'..'9'] then val(s2[i],b[j],code) else b[j]:=ord(s2[i])-87;
end;
c2:=length(s2);
fillchar (sum,sizeof(sum),0);
if c1>c2 then c:=c1 else c:=c2;
for i:=1 to c do begin
sum[i]:=sum[i]+a[i]+b[i];
if sum[i]>=n then begin
sum[i]:=sum[i]-n;
sum[i+1]:=1;
end;
end;
if sum[c+1]<>0 then c:=c+1;
for i:=c downto 1 do if sum[i]>=10 then write (chr(sum[i]+87)) else write (sum[i]);
writeln;
close (output);
end.