program ex(f1,f2);
type
zn=array [1..501] of integer;
var
a,b,c,d:zn; f1,f2:text;
i,j,k,p,m,n,long,now:longint;
next:integer;
begin
assign(f1,'mason.in'); reset(f1);
assign(f2,'mason.out'); rewrite(f2);
readln(f1,n);
for i:=1 to 500 do a[i]:=0;
a[1]:=6; a[2]:=1;
long:=trunc(n*ln(2)/ln(10))+1;
for i:=1 to n-4 do
begin
j:=1; next:=0; now:=trunc((i+4)*ln(2)/ln(10))+1;
while (j<=500)and(j<=now+1) do
begin
p:=next;
if a[j]*2>=10 then next:=1 else next:=0;
a[j]:=(a[j]*2) mod 10+p;
inc(j);
end;
end;
j:=0;
writeln(f2,long);
for i:=500 downto 2 do
begin
write(f2,a[i]);
inc(j);
if j mod 50 =0 then writeln(f2);
end;
writeln(f2,a[1]-1);
close(f1);
close(f2);
end.