#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;


template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first1,
	BidirectionalIterator last1,
	BidirectionalIterator first2,
	BidirectionalIterator last2)
{
	if ((first1 == last1) || (first2 == last2)) {
		return false;
	}
	BidirectionalIterator m1 = last1;
	BidirectionalIterator m2 = last2; --m2;
	while (--m1 != first1 && !(*m1 < *m2)) {
	}
	bool result = (m1 == first1) && !(*first1 < *m2);
	if (!result) {
		// ?
		while (first2 != m2 && !(*m1 < *first2)) {
			++first2;
		}
		first1 = m1;
		std::iter_swap(first1, first2);
		++first1;
		++first2;
	}
	if ((first1 != last1) && (first2 != last2)) {
		// ?
		m1 = last1; m2 = first2;
		while ((m1 != first1) && (m2 != last2)) {
			std::iter_swap(--m1, m2);
			++m2;
		}
		// ?
		std::reverse(first1, m1);
		std::reverse(first1, last1);
		std::reverse(m2, last2);
		std::reverse(first2, last2);
	}
	return !result;
}

template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first,
	BidirectionalIterator middle,
	BidirectionalIterator last)
{
	return next_combination(first, middle, middle, last);
}


int main() {
	string st;
	while (getline(cin, st)) {
		int from = 0;
		vector<string>names;
		for (int i = 0; i < st.size(); ++i) {
			if (st[i] == ' ') {
				names.push_back(st.substr(from, i - from));
				from = i + 1;
			}
		}
		names.push_back(st.substr(from,st.size() - from));
		map<string, int>namemp;
		vector<int>ids;
		int now = 0;
		for (int i = 0; i < 8; ++i) {
			if (namemp.count(names[i])) {
				ids.push_back(namemp[names[i]]);
			}
			else {
				namemp[names[i]] = now;
				ids.push_back(now);
				now++;
			}
		}

		int ans = 0;

		set<vector<int>>octamp;
		vector<int>perm(8);
		iota(perm.begin(), perm.end(), 0);
		do {
			vector<int>colors;
			for (int i = 0; i < 8; ++i) {
				colors.push_back(ids[perm[i]]);
			}
			bool ok = true;
			for (int l = 0; l < 3; ++l) {
				int atem = colors[1];
				colors[1] = colors[3];
				colors[3] = colors[4];
				colors[4] = atem;
				atem = colors[2];
				colors[2] = colors[7];
				colors[7] = colors[5];
				colors[5] = atem;

				for (int i = 0; i < 4; ++i) {
					int tem = colors[0];
					colors[0] = colors[1];
					colors[1] = colors[2];
					colors[2] = colors[3];
					colors[3] = tem;
					tem = colors[4];
					colors[4] = colors[5];
					colors[5] = colors[6];
					colors[6] = colors[7];
					colors[7] = tem;
					if (octamp.count(colors))ok = false;
				}
				swap(colors[0], colors[6]);
				swap(colors[1], colors[5]);
				swap(colors[2], colors[4]);
				swap(colors[3], colors[7]);
				for (int i = 0; i < 4; ++i) {
					int tem = colors[0];
					colors[0] = colors[1];
					colors[1] = colors[2];
					colors[2] = colors[3];
					colors[3] = tem;
					tem = colors[4];
					colors[4] = colors[5];
					colors[5] = colors[6];
					colors[6] = colors[7];
					colors[7] = tem;
					if (octamp.count(colors))ok = false;
				}
			}
			if (ok) {
				ans++;
				for (int l = 0; l < 3; ++l) {
					int atem = colors[1];
					colors[1] = colors[3];
					colors[3] = colors[4];
					colors[4] = atem;
					atem = colors[2];
					colors[2] = colors[7];
					colors[7] = colors[5];
					colors[5] = atem;

					for (int i = 0; i < 4; ++i) {
						int tem = colors[0];
						colors[0] = colors[1];
						colors[1] = colors[2];
						colors[2] = colors[3];
						colors[3] = tem;
						tem = colors[4];
						colors[4] = colors[5];
						colors[5] = colors[6];
						colors[6] = colors[7];
						colors[7] = tem;
						octamp.emplace(colors);
					}
					swap(colors[0], colors[6]);
					swap(colors[1], colors[5]);
					swap(colors[2], colors[4]);
					swap(colors[3], colors[7]);
					for (int i = 0; i < 4; ++i) {
						int tem = colors[0];
						colors[0] = colors[1];
						colors[1] = colors[2];
						colors[2] = colors[3];
						colors[3] = tem;
						tem = colors[4];
						colors[4] = colors[5];
						colors[5] = colors[6];
						colors[6] = colors[7];
						colors[7] = tem;
						octamp.emplace(colors);
					}
				}
			}
				
		} while (next_permutation(perm.begin(), perm.end()));
		cout << ans << endl;
		
	}
	return 0;
}

Measured memory_bytes: 6080