#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int y[8][4]={
	{0,1,2,3},
	{1,0,5,4},
	{2,0,4,6},
	{3,0,6,5},
	{4,7,2,1},
	{5,7,1,3},
	{6,7,3,2},
	{7,4,5,6}
};
set<int> st;
int main(){
	string s[8];
	while(cin>>s[0]>>s[1]>>s[2]>>s[3]>>s[4]>>s[5]>>s[6]>>s[7]){
		st.clear();
		vector<string> ash;
		rep(i,8) ash.pb(s[i]);
		sort(all(ash));
		ash.erase(unique(all(ash)),ash.end());
		int x[8];
		rep(i,8) x[i]=lower_bound(all(ash),s[i])-ash.begin();
		sort(x,x+8);
		do{
			int mn=1e9;
			rep(i,8){
				rep(j,3){
					int z[8];
					z[0]=x[y[i][0]];
					z[1]=x[y[i][(j)%3+1]];
					z[2]=x[y[i][(j+1)%3+1]];
					z[3]=x[y[i][(j+2)%3+1]];
					z[4]=x[7-y[i][(j+2)%3+1]];
					z[5]=x[7-y[i][(j+1)%3+1]];
					z[6]=x[7-y[i][(j)%3+1]];
					z[7]=x[7-y[i][0]];
					int sum=0;
					rep(k,8) sum+=(z[k]<<(3*k));
					mn=min(mn,sum);
				}
			}
			st.insert(mn);
		}while(next_permutation(x,x+8));
		cout<<st.size()<<endl;
	}
}