#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std; 
const int INF = 1e9;

struct octa {
    int face[8];
    void rotate_left(){
        rotate(face, face+1, face+4);
        rotate(face+4, face+5, face+8);
    }

    void rotate_up(){
        int t = face[0];
        face[0] = face[4];
        face[4] = face[7];
        face[7] = face[3];
        face[3] = t;
        t = face[1];
        face[1] = face[5];
        face[5] = face[6];
        face[6] = face[2];
        face[2] = t;
    }

    bool equals(octa o) const {
        if(check(o)) return true;
        o.rotate_up();
        if(check(o)) return true;
        o.rotate_up();
        if(check(o)) return true;
        o.rotate_up();
        if(check(o)) return true;
        o.rotate_up();
        o.rotate_left();
        o.rotate_up();
        if(check(o)) return true;
        o.rotate_up();
        o.rotate_up();
        if(check(o)) return true;
        return false;
    }

    bool check(octa &o) const {
        rep(i,4){
            if(equal(face, face+8, o.face)) return true;
            o.rotate_left();
        }
        return false;
    }
};

int main(){
    string s[8];
    while(cin >> s[0]){
        rep(i,7) cin >> s[i+1];
        map<string, int> m;
        int k = 0;
        rep(i,8) if(m.count(s[i]) == 0) m[s[i]] = k++;
        octa o;        
        rep(i,8) o.face[i] = m[s[i]];

        sort(o.face, o.face+8);
        vector<octa> s;
        s.push_back(o);
        do {
            bool add = true;
            for(auto &a : s){
                if(a.equals(o)){
                    add = false;
                    break;
                }
            }
            if(add) s.push_back(o);
        } while(next_permutation(o.face+1, o.face+8));
        cout << s.size() << endl;
    }
}