n=int(input()) ans=3**(n//3) if n%3==1: ans=ans/3*4 elif n%3==2: ans*=2 s='%d' %ans print(len(s)) print(s[0:100])