program grey; var o:text; n,i,i2:real;i3,m:integer;n2,m2:double; begin assign(o,'grey.dat'); reset(o); readln(o,n); close(o); n:=n+1; while(n<>1)and(n<>2)and(n<>3)and(n<>4)do begin m:=2; i:=4; m2:=1; while(n>i)do begin i2:=i; i:=i*2; m:=m+1; end; for i3:=1 to m-1 do m2:=m2*10; n2:=n2+m2; i:=n-i2; n:=i2-(i-1); end; if n=2 then n2:=n2+1 else if n=3 then n2:=n2+11 else if n=4 then n2:=n2+10; assign(o,'grey.sol'); rewrite(o); writeln(o,n2); close(o); end.