#include<iostream>
using namespace std;
const int N = 10, M = 7;
int e[N][N] = {0}, f[N], open[N];
long long ans = 0;
int find(int x){
if(f[x] == x) return x;
return f[x] = find(f[x]);
}
void dfs(int n){
if(n == 8){
for(int i = 1; i <= M; i++) {
f[i] = i;
}
for(int i = 1; i <= M; i++){
for(int j = 1; j <= M; j++){
if(e[i][j] && open[i] && open[j]){
f[find(i)] = find(j);
}
}
}
int cnt = 0;
for(int i = 1; i <= M; i++){
if(open[i] && f[i] == i) cnt++;
}
if(cnt == 1) ans++;
return;
}
open[n] = 1;
dfs(n + 1);
open[n] = 0;
dfs(n + 1);
}
int main(){
e[1][2] = e[1][6] = 1;
e[2][1] = e[2][3] = e[2][7] = 1;
e[3][2] = e[3][7] = e[3][4] = 1;
e[4][3] = e[4][5] = 1;
e[5][4] = e[5][7] = e[5][6] = 1;
e[6][1] = e[6][7] = e[6][5] = 1;
e[7][2] = e[7][3] = e[7][6] = e[7][5] = 1;
dfs(1);
cout << ans;
return 0;
}