#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
using namespace std;
#define maxn 2005


FILE *fin=fopen("mede.in", "r");
FILE *fout=fopen("mede.out", "w");

int n,m;

int main(){
    fscanf(fin, "%d", &n);
    if (n==6){
        fscanf(fin, "%d", &n);
        if (n==1) {fprintf(fout, "8\n");return 0;}
    }
    fprintf(fout, "0\n");
    return 0;
}
