import java.util.*; public class Main { static long cul(long p){ if(p==1){ return 3; } return cul(p-1)*3+(cul(p-1)+1)*3+(cul(p-1)+2)*3+((long)Math.pow(10, p-1)-1); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); long P = sc.nextLong(); System.out.println(cul(P)); } }