#include <bits/stdc++.h>
using namespace std;
const int vx[] = {3, 2, 6, 7, 0, 1, 5, 4};
const int vy[] = {4, 0, 3, 7, 5, 1, 2, 6};
const int vz[] = {1, 2, 3, 0, 5, 6, 7, 4};

vector< string > rollX(vector< string >& t)
{
  vector< string > u(8);
  for(int i = 0; i < 8; i++) u[i] = t[vx[i]];
  return(u);
}
vector< string > rollY(vector< string >& t)
{
  vector< string > u(8);
  for(int i = 0; i < 8; i++) u[i] = t[vy[i]];
  return(u);
}
vector< string > rollZ(vector< string >& t)
{
  vector< string > u(8);
  for(int i = 0; i < 8; i++) u[i] = t[vz[i]];
  return(u);
}

int main()
{
  string s[8];
  while(cin >> s[0]) {
    for(int i = 1; i < 8; i++) cin >> s[i];
    sort(s, s + 8);
    set< vector< string > > ss;
    int ret = 0;
    do {
      vector< string > buff(s, s + 8);
      if(ss.find(buff) == ss.end()) {
        ++ret;
        for(int i = 0; i < 4; i++) {
          for(int j = 0; j < 4; j++) {
            for(int k = 0; k < 4; k++) {
              ss.insert(buff);
              buff = rollX(buff);
            }
            buff = rollY(buff);
          }
          buff = rollZ(buff);
        }
      }
    } while(next_permutation(s, s + 8));
    cout << ret << endl;
  }
}