import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int x= scanner.nextInt();
int w=1;//用来每次乘以6
int z=0;//存储累加值
int u=0;
for(int h=x;h>0;h--) {
for (int i = x; x > 0; x--) {
w = w * 6;
z += w;
}
}
u=z%7;
System.out.println(u);
}
}