import java.util.Scanner; import java.math.BigInteger; public class Yuki220 { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int p=sc.nextInt(); long ary1[],ary2[],ary3[],ary4[]; ary1=new long[19]; ary2=new long[19]; ary3=new long[19]; ary4=new long[19]; String S="1"; int h=1; for(int i=0;i<19;++i){ S+="0"; long b=0,d=0,e=0; BigInteger bi_div=new BigInteger("3"); BigInteger bi_a=new BigInteger(S); bi_a=bi_a.divide(bi_div); long b1_2=1; for(int j=0;j=0;--j){ long b3=ary1[j]; long b3_2=1; for(int k=0;k=0) d1=ary2[i-1]; if(i-2>=0) d2=ary2[i-2]; if(i-2>=0) d3=d1-d2; d4=d1*3; d5=d3*6; if(i-1>=0) d5+=ary3[i-1]; ary3[i]=d5; d6=1; for(int j=0;j