Vasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is because she cannot open the box. She hopes that you can help her in that.The box's lock is constructed like that. The box itself is represented by an absolutely perfect black cube with the identical deepening on each face (those are some foreign nanotechnologies that the far away kingdom scientists haven't dreamt of). The box is accompanied by six gems whose form matches the deepenings in the box's faces. The box can only be opened after it is correctly decorated by the gems, that is, when each deepening contains exactly one gem. Two ways of decorating the box are considered the same if they can be obtained one from the other one by arbitrarily rotating the box (note that the box is represented by a perfect nanotechnological cube)Now Vasilisa the Wise wants to know by the given set of colors the following: in how many ways would she decorate the box in the worst case to open it? To answer this question it is useful to know that two gems of one color are indistinguishable from each other. Help Vasilisa to solve this challenging problem.

The first line contains exactly 6 characters without spaces from the set {R, O, Y, G, B, V} — they are the colors of gems with which the box should be decorated.

Print the required number of different ways to decorate the box.

    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    #include <climits>
    #include <set>
    using namespace std;
    struct Cube
    {
            char str[7];
            bool operator<(const Cube& other) const
            {
                    return strcmp(str,other.str)<0;
            }
    };
    int main()
    {
            int n;
            Cube cube;
            set<Cube> patterns;
            while(scanf("%s",cube.str)==1)
            {
                    sort(cube.str,cube.str+6);
                    patterns.clear();
                    int ans=0;
                    do
                    {
                            bool ok=true;
                            Cube tmp1,tmp2,tmp3;
                            if(patterns.count(cube)==0)
                            {
                                    ans++;
                                    //type1
                                    strcpy(tmp1.str,cube.str);
                                    for(int i=0;i<4;++i)
                                    {
                                            char ch=tmp1.str[0];
                                            tmp1.str[0]=tmp1.str[3];
                                            tmp1.str[3]=tmp1.str[5];
                                            tmp1.str[5]=tmp1.str[1];
                                            tmp1.str[1]=ch;
                                            strcpy(tmp2.str,tmp1.str);
                                            for(int j=0;j<4;++j)
                                            {
                                                    char ch=tmp2.str[0];
                                                    tmp2.str[0]=tmp2.str[4];
                                                    tmp2.str[4]=tmp2.str[5];
                                                    tmp2.str[5]=tmp2.str[2];
                                                    tmp2.str[2]=ch;
                                                    strcpy(tmp3.str,tmp2.str);
                                                    for(int k=0;k<4;++k)
                                                    {
                                                            char ch=tmp3.str[1];
                                                            tmp3.str[1]=tmp3.str[4];
                                                            tmp3.str[4]=tmp3.str[3];
                                                            tmp3.str[3]=tmp3.str[2];
                                                            tmp3.str[2]=ch;
                                                            //puts(tmp3.str);
                                                            patterns.insert(tmp3);
                                                    }
                                            }
                                    }
                                    //puts(cube.str);
                            //      printf("%d",patterns.size());
                            }
                    }while(next_permutation(cube.str,cube.str+6));
                    printf("%d\n",ans);
            }
    }
/****** PCCA -Sat Aug 06 08:16:20 GMT 2011 *******/

#include<cstdio>
#include<set>
#include<queue>
#include<algorithm>
using namespace std;
const int to[3][6]=
{
    //{1,2,3,4,5,6}
    {2,3,4,1,5,6},
    {1,5,3,6,4,2},
    {5,2,6,4,3,1}
};
struct states
{
    int pos[6];
};
class cmp
{
    public :
    bool operator()(const states & x, const states & y)
      {
        for (int i=0;i<6;i++)
            if (x.pos[i]!=y.pos[i])
                return x.pos[i]<y.pos[i];
        return 0;
      }
};
set<states,cmp> st,ans;
queue<states> que;
void bfs()
{
    states tmp;
    for (int i=0;i<6;i++)
        tmp.pos[i]=i+1;
    que.push(tmp);
    st.insert(tmp);
    while (!que.empty())
    {
        states now=que.front();
        que.pop();
        for (int i=0;i<3;i++)
        {
            states newst=now;
            for (int j=0;j<6;j++)
                newst.pos[j]=to[i][newst.pos[j]-1];
            if (st.find(newst)==st.end())
            {
                st.insert(newst);
                que.push(newst);
            }
        }
    }
}
char s[7],a[6];
int main()
{
    bfs();
    gets(s);
    for (int i=0;i<6;i++)
    {
        if (s[i]=='R')
            a[i]=0;
        if (s[i]=='O')
            a[i]=1;
        if (s[i]=='Y')
            a[i]=2;
        if (s[i]=='G')
            a[i]=3;
        if (s[i]=='B')
            a[i]=4;
        if (s[i]=='V')
            a[i]=5;
    }
    sort(a,a+6);
    do
    {
        states tmp;
        for (int i=0;i<6;i++)
            tmp.pos[i]=a[i];
        bool flag=1;
        for (set<states> :: iterator it=st.begin();it!=st.end();it++)
        {
            states newst;
            for (int i=0;i<6;i++)
                newst.pos[i]=tmp.pos[(*it).pos[i]-1];
            if (ans.find(newst)!=ans.end())
            {
                flag=0;
                break;
            }
        }
        if (flag)
            ans.insert(tmp);
    }
    while (next_permutation(a,a+6));
    printf("%d\n",ans.size());
    /*for (set<states> :: iterator it=ans.begin();it!=ans.end();it++,puts(""))
        for (int i=0;i<6;i++)
            printf("%d ",(*it).pos[i]);*/
    return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

char buf[0xf];
int ans[0xf];

int main()
{
	int i, k, last;
	while (~scanf("%s", buf))
	{
		memset(ans, 0, sizeof(ans));
		sort(buf, buf+6);
		for (k = last = i = 0; i < 6; i++)
		{
			if (buf[i] == last)
				ans[k]++;
			else
			{
				last = buf[i];
				ans[++k]++;
			}
		}
		sort(ans+1, ans+k+1);
		if (k == 1)
			puts("1");
		else if (k == 2)
		{
			if (ans[1] == 1)
				puts("1");
			else
				puts("2");
		}
		else if (k == 3)
		{
			if (ans[2] == 1)
				puts("2");
			else if (ans[3] == 2)
				puts("6");
			else
				puts("3");
		}
		else if (k == 4)
		{
			if (ans[3] == 1)
				puts("5");
			else
				puts("8");
		}
		else if (k == 5)
			puts("15");
		else
			puts("30");
	}
	return 0;
}

    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    #include <climits>
    #include <set>
    using namespace std;
    struct Cube
    {
            char str[7];
            bool operator<(const Cube& other) const
            {
                    return strcmp(str,other.str)<0;
            }
    };
    int main()
    {
            int n;
            Cube cube;
            set<Cube> patterns;
            while(scanf("%s",cube.str)==1)
            {
                    sort(cube.str,cube.str+6);
                    patterns.clear();
                    int ans=0;
                    do
                    {
                            bool ok=true;
                            Cube tmp1,tmp2,tmp3;
                            if(patterns.count(cube)==0)
                            {
                                    ans++;
                                    //type1
                                    strcpy(tmp1.str,cube.str);
                                    for(int i=0;i<4;++i)
                                    {
                                            char ch=tmp1.str[0];
                                            tmp1.str[0]=tmp1.str[3];
                                            tmp1.str[3]=tmp1.str[5];
                                            tmp1.str[5]=tmp1.str[1];
                                            tmp1.str[1]=ch;
                                            strcpy(tmp2.str,tmp1.str);
                                            for(int j=0;j<4;++j)
                                            {
                                                    char ch=tmp2.str[0];
                                                    tmp2.str[0]=tmp2.str[4];
                                                    tmp2.str[4]=tmp2.str[5];
                                                    tmp2.str[5]=tmp2.str[2];
                                                    tmp2.str[2]=ch;
                                                    strcpy(tmp3.str,tmp2.str);
                                                    for(int k=0;k<4;++k)
                                                    {
                                                            char ch=tmp3.str[1];
                                                            tmp3.str[1]=tmp3.str[4];
                                                            tmp3.str[4]=tmp3.str[3];
                                                            tmp3.str[3]=tmp3.str[2];
                                                            tmp3.str[2]=ch;
                                                            //puts(tmp3.str);
                                                            patterns.insert(tmp3);
                                                    }
                                            }
                                    }
                                    //puts(cube.str);
                            //      printf("%d",patterns.size());
                            }
                    }while(next_permutation(cube.str,cube.str+6));
                    printf("%d\n",ans);
            }
    }
/****** PCCA -Mon Aug 08 16:46:27 GMT 2011 *******/

/////////////////////////////////////////////////
// *** Solution By Bektemir Doolotbek uulu *** //
/////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define buli(x) __builtin_popcountll(x)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double d;

const int mod=1000000007;
const int N=1001;
const int M=100005;
const ld pi=acos(-1);

string s;
set<string> st;
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> s;
	sort( s.begin(), s.end() );
	do {
		vector< string > v;
		for( int i = 0; i < 3; i++ ) {
			v.push_back( s.substr( 2 * i, 2 ) );
			sort( v.back().begin(), v.back().end() );
		}
		sort( v.begin(), v.end() );
		string tmp = v[0] + v[1] + v[2];
		st.insert( tmp );
		if( v[0] != v[1] && v[1] != v[2] && v[2] != v[0] && tmp[0] != tmp[1] && tmp[2] != tmp[3] ) {
			swap( tmp[4], tmp[5] );
			st.insert( tmp );
		}
	} while( next_permutation( s.begin(), s.end() ) );
	cout << st.size() << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using std::string;
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define FORR(i,l,r) for(int (i)=l;(i)<(r);++(i))
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define EPSILON 1e-9
#define MAX 100002
#define PI 3.1415926535897932384626433832795028841971693993751
typedef long long  ll;
typedef unsigned long long llu;
typedef long double  ldb;
typedef double  db ;
void rotate1(string &t)
{
    char temp=t[1];
    t[1]=t[0];
    t[0]=t[3];
    t[3]=t[2];
    t[2]=temp;
}
void rotate2(string &t)
{
    char temp=t[1];
    t[1]=t[4];
    t[4]=t[3];
    t[3]=t[5];
    t[5]=temp;
}
void rotate3(string &t)
{
    char temp=t[0];
    t[0]=t[4];
    t[4]=t[2];
    t[2]=t[5];
    t[5]=temp;

}
string norm(string s)
{
    string res=s;
    FOR(i,2)
    {
        FOR(j,4)
        {
            FOR(k,4)
            {
                rotate1(s);
                res=min(res,s);
            }
            rotate3(s);
        }
        rotate1(s);
    }
    return res;
}
int main()
{
    //freopen("in.txt","r",stdin);
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    set<string>S;
    do
    {
        S.insert(norm(s));
    }
    while(next_permutation(s.begin(),s.end()));
    cout<<S.size()<<endl;

}

#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <memory.h>
#include <cstdio>

using namespace std;

#define pb push_back
#define INF 1000000001
#define FOR(i,a,b) for (int _n(b), i(a); i < _n; i++)
#define rep(i,n) FOR(i,0,n)
#define ford(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define CL(a,v) memset((a),(v),sizeof(a))
#define mp make_pair
#define X first
#define Y second
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;

string rotOz(const string &s)
{
    string a = s;

    a[0] = s[4];
    a[2] = s[0];
    a[5] = s[2];
    a[4] = s[5];

    return a;
}

string rotOx(const string &s)
{
    string a = s;

    a[1] = s[4];
    a[2] = s[1];
    a[3] = s[2];
    a[4] = s[3];

    return a;
}

string rotOy(const string &s)
{
    string a = s;

    a[0] = s[1];
    a[1] = s[5];
    a[5] = s[3];
    a[3] = s[0];

    return s;
}

set<string> was;

void gen(const string &s)
{
    if(was.count(s)) return;

    was.insert(s);

    string s1 = rotOx(s);
    gen(s1);

    string s2 = rotOy(s);
    gen(s2);

    string s3 = rotOz(s);

    gen(s3);
}

set<string> cash;

int main()
{
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
	#endif

    was.clear();
    gen("012345");

    //cout << was.size() << endl;

    string C;
    cin >> C;
    SORT(C);

    cash.clear();

    int ans = 0;

    do
    {
        if(cash.count(C)) continue;
        ++ans;

        for(set<string> :: iterator it = was.begin(); it != was.end(); ++it)
        {
            const string &a = *it;

            string n = C;

            rep(i,C.size())
            {
                n[i] = C[ a[i] - '0' ];
            }

            cash.insert(n);
        }
    }
    while( next_permutation(all(C)) );

    cout << ans << endl;

	return 0;
}

#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
int main()
{
    string s="ROYGBV",str;
    int m[6],count[7],i;
    while(cin>>str)
    {
        memset(m,0,sizeof(m));
        memset(count,0,sizeof(count));
        for(i=0;i<6;++i)
        {
            m[s.find(str[i])]++;
        }
        for(i=0;i<6;++i)
        {
            count[m[i]]++;
        }
        if(count[6]==1||count[5]==1) cout<<1<<endl;
        else if((count[2]==1&&count[4]==1)||(count[3]==2)||(count[1]==2&&count[4]==1)) cout<<2<<endl;
        else if(count[2]==3) cout<<6<<endl;
        else if(count[1]==1&&count[2]==1&&count[3]==1) cout<<3<<endl;
        else if(count[1]==3&&count[3]==1) cout<<5<<endl;
        else if(count[1]==2&&count[2]==2) cout<<8<<endl;
        else if(count[1]==4) cout<<15<<endl;
        else if(count[1]==6) cout<<30<<endl;
        str.clear();
    }
    return 0;
}

#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;
int f[7];
char a[7];

int ans(int x){
    if (x == 7) return 1;
    if (x == 12) return 1;
    if (x == 15) return 2;
    if (x == 16) return 2;
    if (x == 20) return 2;
    if (x == 24) return 3;
    if (x == 27) return 6;
    if (x == 32) return 5;
    if (x == 36) return 8;
    if (x == 48) return 15;
    if (x == 64) return 30;
    }

int main(){
    gets(a + 1);
    sort(a + 1, a + 7);
    int l = 1;
    for (int i = 1; i <= 6; i++) f[i] = 1;
    f[1] ++;
    for (int i = 2; i <= 6; i++)
        if (a[i] == a[i - 1]) f[l] ++;
        else f[++l] ++;
    //scout << f[1] << f[2] << f[3] << endl;
    int x = f[1] * f[2] * f[3] * f[4] * f[5] * f[6];
    printf("%d", ans(x));
    return 0;
}

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cassert>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
#define DB(x) { cerr << #x << ": " << x << " "; }
#define forn(i, n)  for (int i = 0; i < (int)(n); ++i)
#define sqr(x) ((x)*(x))
typedef long double ld;
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pii;
const ld PI = acos(-1.0);

ll fact(int x) {
    ll res = 1;
    for (int i = 2; i <= x; i++)
            res *= i;
    return res;
}

int main() {
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    //ios_base::sync_with_stdio(0);

    string s;
    cin >> s;
    map<char, int> m;
    forn(i, s.size()) m[s[i]]++;
    vi all;
    for (map<char,int>::iterator it = m.begin(); it != m.end(); it++)
        all.push_back(it->second);
    sort(all.begin(), all.end());
    if (all.size() == 1) cout << 1 << endl;
    else if (all.size() == 2) { if(all[1] == 5) cout << 1 << endl; else if (all[1] == 4) cout << 2 << endl; else cout << 2 << endl; }
    else if (all.size() == 3) { if(all[2] == 4) cout << 2 << endl; else if (all[2] == 3) cout << 3 << endl; else cout << 6 << endl;}

    else if (all.size() == 4) { if (all[3] == 3) cout << 5 << endl; else cout << 8 << endl; }
    else if (all.size() == 5) cout << 15 << endl;

    else cout << 30 << endl;
    return 0;
}

#include<iostream>
#define pb push_back
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef pair<int,int> P;
int main(){
    set<char> st;
    string s;

    cin>>s;
    int m=0;
    map<char,int> mp;
    for(int i=0;i<6;i++){
        mp[s[i]]++;
        m=max(m,mp[s[i]]);
        st.insert(s[i]);
    }
    int n=st.size();
    if(n==1){
        cout<<1<<endl;
    }else if(n==6){
        cout<<30<<endl;
    }else if(n==5){
        cout<<15<<endl;
    }else if(n==2){
        if(m==5)
            cout<<1<<endl;
        else
            cout<<2<<endl;
    }else if(n==3){
        if(m==4)
            cout<<2<<endl;
        else if(m==3)
            cout<<3<<endl;
        else
            cout<<6<<endl;
    }else{
        if(m==3)
            cout<<5<<endl;
        else
            cout<<8<<endl;
    }

    return 0;
}

#define _CRT_SECURE_NO_DEPRECATE
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
#include <stack>
#include <cstring>
#include <ctime>
#include <cstdio>
#include <memory>
using namespace std;
#define pb push_back
#define INF 1000000000
#define L(s) (int)((s).end()-(s).begin())
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define rep(i,n) FOR(i,1,(n))
#define rept(i,n) FOR(i,0,(n)-1)
#define C(a) memset((a),0,sizeof(a))
#define ll long long
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define VI vector<int>
#define ppb pop_back
#define mp make_pair
#define pii pair<int,int>
#define pdd pair<double,double>
//#define x first
//#define y second
#define sqr(a) (a)*(a)
#define D(a,b) sqrt(((a).x-(b).x)*((a).x-(b).x)+((a).y-(b).y)*((a).y-(b).y))
#define pi 3.1415926535897932384626433832795028841971
//#define tt (ll+rr)/2
#define UN(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define rnd() ((rand() << 16) ^ rand())

string turnRight(string s)
{
	string p = "";
	p += s.substr(0, 4);
	rotate(p.begin(), p.begin() + 1, p.end());
	rept(i, 4)
		s[i] = p[i];

	return s;
}

string turnDown(string s)
{
	string p = "";
	p += s[1];
	p += s[4];
	p += s[3];
	p += s[5];

	rotate(p.begin(), p.begin() + 1, p.end());

	s[1] = p[0];
	s[4] = p[1];
	s[3] = p[2];
	s[5] = p[3];

	return s;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","rt",stdin); freopen("output.txt","wt",stdout);
    #endif

	string s;
	cin >> s;
	SORT(s);
	int res = 0;
	set<string> used;
	do
	{
		if (used.find(s) == used.end())
			res++;
		rept(i, 10)
			rept(j, 10)
			{
				string temp = s;
				rept(ci, i)
					temp = turnRight(temp);
				rept(ci, j)
					temp = turnDown(temp);
				used.insert(temp);
			}
	}
	while (next_permutation(all(s)));

	cout << res << endl;
    return 0;
}

#include <cstdio>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
set <string> a;
char buf[10];
const int c[7][4]={{0},{2,3,5,6},{6,4,3,1},{5,1,2,4},{2,6,5,3},{6,1,3,4},{4,2,1,5}};
int calc(int x)
{
    return(x<=3?x+3:x-3);
}
void work(string s)
{
    string q;
    q.resize(6);
    for (int i=1;i<=6;i++)
        for (int j=0;j<4;j++)
        {
            int x=i,y=c[i][j],z=c[i][(j+1)%4];
            q[0]=s[x-1],q[1]=s[y-1],q[2]=s[z-1],q[3]=s[calc(x)-1],q[4]=s[calc(y)-1],q[5]=s[calc(z)-1];
            a.insert(q);
        }
}
int main()
{
    scanf("%s",buf);
    string s(buf);
    sort(s.begin(),s.end());
    int ans=0;
    while (1)
    {
        if (!a.count(s))
        {
            ans++;
            work(s);
        }
        if (!next_permutation(s.begin(),s.end()))
            break;
    }
    printf("%d\n",ans);
    return(0);
}

#pragma warning(disable:4786)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<cstdio>
#include <ctime>

using namespace std;

#define MEM(a,b) memset(a,(b),sizeof(a))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b)  ((a) < (b) ? (a) : (b))
#define istr(S) istringstream sin(S)
#define MP make_pair
#define pb push_back
#define inf 1000000000
#define maxn 1000000

//typedef long long  LL;

typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<pi> vpi;

typedef __int64 LL;

int arr[24][6]={
{0,1,2,3,4,5},{0,5,1,3,2,4},{0,4,5,3,1,2},{0,2,4,3,5,1},
{1,3,2,4,0,5},{1,5,3,4,2,0},{1,0,5,4,3,2},{1,2,0,4,5,3},
{2,1,3,5,4,0},{2,0,1,5,3,4},{2,4,0,5,1,3},{2,3,4,5,0,1},
{3,1,5,0,4,2},{3,2,1,0,5,4},{3,4,2,0,1,5},{3,5,4,0,2,1},
{4,3,5,1,0,2},{4,2,3,1,5,0},{4,0,2,1,3,5},{4,5,0,1,2,3},
{5,1,0,2,4,3},{5,3,1,2,0,4},{5,4,3,2,1,0},{5,0,4,2,3,1}
};

string cols,cube;
map<string,int> S;

int bktk(int pos,int flag)
{
    int j,i,ret=0;

    if(pos==6)
    {
        if(S.find(cube)!=S.end()) return 0;

        //printf("%s\n",cube.c_str());
        for(i=0;i<24;i++)
        {
            string tmp;
            for(j=0;j<6;j++)
                tmp+=cube[arr[i][j]];
        //  if(S.find(tmp)!=S.end()) printf("%s %s\n",cube.c_str(),tmp.c_str());
            S[tmp]=1;
        }
        return 1;
    }

    for(i=0;i<6;i++)
    {
        if(flag&(1<<i)) continue;
        cube[pos]=cols[i];
        ret+=bktk(pos+1,flag|(1<<i));
    }
    return ret;
}

int main()
{
    int i,j,k,tests,cs=0,n;
    string s;

    cin>>cols;

        cube=cols;
        int ans=bktk(0,0);
        printf("%d\n",ans);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define paii pair<int,int>
#define MK(a,b) make_pair(a,b)
string s,c;
char cc[10];
bool vis[10];
map<string,bool>ma;
int sum;
void dfs(int o){
	if (o==6){
		cc[o]='\0';
		c=cc;
		if (ma[c])
			return;
		sum++;
		queue<string>q;
		q.push(c);
		while (!q.empty()){
			string p=q.front();
			q.pop();
			string s1=p,s2=p,s3=p;
			s1[0]=p[3];
			s1[1]=p[0];
			s1[2]=p[1];
			s1[3]=p[2];
			s2[0]=p[4];
			s2[2]=p[5];
			s2[4]=p[2];
			s2[5]=p[0];
			s3[1]=p[4];
			s3[3]=p[5];
			s3[5]=p[1];
			s3[4]=p[3];
			if(!ma[s1]){
				ma[s1]=true;
				q.push(s1);
			}
			if(!ma[s2]){
				ma[s2]=true;
				q.push(s2);
			}
			if(!ma[s3]){
				ma[s3]=true;
				q.push(s3);
			}
		}
		return;
	}
	rep(i,0,5){
		if (!vis[i]){
			vis[i]=true;
			cc[o]=s[i];
			dfs(o+1);
			vis[i]=false;
		}
	}
}
void solve(){
	ios::sync_with_stdio(false);
	mem(vis,false);
	cin>>s;
	sum=0;
	dfs(0);
	cout<<sum<<endl;
}
int main(){
	solve();
	return 0;
}

/*
111111	1
211111	1
221111	2
222111
321111
322111
332211
432111
432211
543211
654321	30

*/

/*
Lay it, lay it down, let me see your hand
Show me what you got
You're always talking, but you're not playing
It doesn't match your face
Gotta find my way, away from this place
Can you take me now?
I-I want it, I want it real
Are you afraid of me now?
Are you afraid of me now?

Do you feel it, do you feel it?
Do you feel that I can see your soul?
Do you feel it, do you feel it?
Do you feel the beat in your heart?

I-I want it, I want it real
Run away with me now
I-I want it, I want it real
Run away with me now

Somedays I'm built of metal, I can't be broken
But not when I'm with you
You love me real, we have it all
Can't leave me now
I love the way, you are today
Run away with me now
Wind in my hair, 'cause I don't care
Baby, run away with me now
Run away with me now

Do you feel it, do you feel it?
Do you feel that I can see your soul?
Do you feel it, do you feel it?
Do you feel the beat in your heart?

I-I want it, I want it real
Run away with me now
I-I want it, I want it real
Run away with me now

Oh, oh
Oh oh
Oh, oh
Oh oh

Drinking in the summer, I'm good at running
I beat you in the race again
Are you afraid, when I look your way?
It's easiest to stay at home
But then we taste it, we got to have it
We have no control
Where is the love, the kind we dream of?
The kind that makes us young
The kind that makes us young

Don't leave me
Never leave me out
Don't leave me
Never leave me out
Don't leave me
Never leave me out
Don't leave me
Never leave me out
Don't leave me
Never leave me out
Don't leave me
Never leave me out
*/

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define gcd(a,b) __gcd(a,b)

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define filewr() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = 3.1415926535897932384626433832795;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;  // find_by_order() , order_of_key()

int main(){

	string s;
	cin >> s;

	int a[6]={0};

	for(int i=0;i<6;i++){

		if(s[i]=='R')a[0]++;
		if(s[i]=='O')a[1]++;
		if(s[i]=='Y')a[2]++;
		if(s[i]=='G')a[3]++;
		if(s[i]=='B')a[4]++;
		if(s[i]=='V')a[5]++;
	}

	sort(a,a+6,greater<>());

	int ans;

	if(a[0]==1 && a[1]==1 && a[2]==1 && a[3]==1 && a[4]==1 && a[5]==1 ) ans = 30;
	if(a[0]==2 && a[1]==1 && a[2]==1 && a[3]==1 && a[4]==1) ans = 15;
	if(a[0]==2 && a[1]==2 && a[2]==1 && a[3]==1)ans = 8;
	if(a[0]==3 && a[1]==1 && a[2]==1 && a[3]==1) ans = 5;
	if(a[0]==4 && a[1]==1 && a[2]==1) ans = 2;
	if(a[0]==2 && a[1]==2 && a[2]==2) ans = 6;
	if(a[0]==3 && a[1]==2 && a[2]==1) ans = 3;
	if(a[0]==5 && a[1]==1) ans = 1;
	if(a[0]==3 && a[1]==3) ans = 2;
	if(a[0]==4 && a[1]==2) ans = 2;
	if(a[0]==6)ans = 1;

	cout << ans << endl;

	return 0;
}

#pragma warning(disable:4786)
#include<cstdio>
#include<set>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
set<string>S;
void dfs(string s)
{
	if(S.find(s)!=S.end())return;
	S.insert(s);
	char s1[]={s[1],s[2],s[3],s[0],s[4],s[5],0};
	dfs(s1);
	char s2[]={s[0],s[4],s[2],s[5],s[3],s[1],0};
	dfs(s2);
}
int main()
{
	int ans=0;
	char s[10];
	cin>>s;
	sort(s,s+6);
	do
	{
		if(S.find(s)!=S.end())continue;
		ans++;
		dfs(s);
	}while(next_permutation(s,s+6));
	printf("%d\n",ans);
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <algorithm>
using namespace std;
typedef long long LL;
#define eps (1e-8)
string rolt[]= {
    "012345",
    "023415",
    "034125",
    "041235",
    "104523",
    "145203",
    "152043",
    "120453",
    "215304",
    "253014",
    "230154",
    "201534"
};
bool equal(string a,string b)
{
    for(int i=0;i<12;i++)
    {
        string res="";
        for(int j=0;j<6;j++)
        {
            res+=a[rolt[i][j]-'0'];
        }
        //cout<<"str= "<<res<<"b= "<<b<<endl;
        if(res==b) return true;
        string tmp=rolt[i];
        reverse(tmp.begin(),tmp.end());
        res.clear();
        for(int j=0;j<6;j++)
        {
            res+=a[tmp[j]-'0'];
        }
       // cout<<"str= "<<res<<"b= "<<b<<endl;
        if(res==b) return true;
    }
    return false;
}
int main()
{
    string str;
    cin>>str;

    sort(str.begin(),str.end());
    vector<string> res;

    do
    {
        bool flag=0;
        for(int i=0;i<(int)res.size();i++)
        {
            if(equal(str,res[i])) {flag=1;break;}
        }
        if(!flag) res.push_back(str);
    }while(next_permutation(str.begin(),str.end()));

    //for(int i=0;i<(int)res.size();i++) printf("%s\n",res[i].c_str());
    cout<<(int)res.size()<<endl;
    return 0;
}

#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>

using namespace std;

#define spc        printf(" ")
#define nln        puts("")                         ///printnewline
#define Max(a,b,c) max(a,max(b,c))                  ///3 ta theke max
#define Min(a,b,c) min(a,min(b,c))                  ///3 ta theke min
#define sqr(x)     (x)*(x)

#define z(x)       fabs(x)<EPS
#define iqu(x,y)   z(fabs(x-y))

#define rep(i,a,b)  for(i=a;i<=b;i++)
#define rep0(i,n)   for(i=0;i<n;i++)
#define rep1(i,n)   for(i=1;i<=n;i++)               ///looping
#define rev(i,a,b)  for(i=a;i>=b;i--)
#define rev0(i,n)   for(i=n-1;i>=0;i--)
#define rev1(i,n)   for(i=n;i>=1;i--)
#define forstl(i,v) for(i=0;i<v.size();i++)
#define forit(it,v)    for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(p)      p.begin(),p.end()

#define SET(p)     memset(p,-1,sizeof(p))
#define CLR(p)     memset(p,0,sizeof(p))            ///memset
#define MEM(p,v)   memset(p,v,sizeof(p))

#define READ(f)    freopen(f, "r", stdin)           /// file
#define WRITE(f)   freopen(f, "w", stdout)

#define vi         vector<int>
#define vll        vector<long long>
#define vs         vector<string>
#define pii        pair<int,int>
#define pll        pair<long long,long long>
#define sz(c)      (int)c.size()
#define pb(x)      push_back(x)                     ///STL defines
#define mp(x,y)    make_pair(x,y)
#define xx         first
#define yy         second
#define _itr(v)    __typeof(v.begin())

#define LLI        long long int
#define i64        long long int
#define i64u       unsigned long long int
#define LLU        unsigned long long int
#define Double     long double
#define PI         acos(-1.0)                        ///PI er value

#define check(n, pos)  (bool)(n & (1LL<<(pos)))      ///CHECK
#define biton(n, pos)  (n | (1LL<<(pos)))            ///ON     }-bit opr.
#define bitoff(n, pos) (n & ~(1LL<<(pos)))           ///OFF

// reading and writing case
#define readcase  int cas,kase=0;CI(cas);while((cas--)&&(++kase))
#define printcase printf("Case %d:",kase)

//debugging infinite variable
bool deb_mode = 0;
#define debug(a...)     if(deb_mode){cout<<"Line= "<<__LINE__<<" -> ";Dbug,a,#a;Dbug.printall();cout<<endl;}
class debugger {
    vector<string> vars;
public:
    template<typename T> debugger& operator , ( const T v ) { stringstream ss; ss << v, vars.push_back( ss.str() ); return *this; }
    void printall() { int j = 0, l = vars.size(); for( int i = 0; i < ( l - 1 ); i++ ) { if( i )cout << ", "; for( j; j < vars[l - 1].size(); j++ ) { if( vars[l - 1][j] == ',' ) {j++; break;} cout << vars[l - 1][j]; } cout << " = " << vars[i]; } vars.clear(); }
} Dbug;

///STL printing output stream overloading
template <typename T1, typename T2> inline ostream& operator << ( ostream& os, const pair<T1, T2>& p ) { return os << "(" << p.first << "," << p.second << ")"; }
template <typename T> inline ostream &operator << ( ostream & os, const vector<T>& v ) { bool first = true; os << "{"; for( unsigned int i = 0; i < v.size(); i++ ) { if( !first ) os << ","; os << v[i]; first = false; } return os << "}"; }
template <typename T> inline ostream &operator << (  ostream & os, const set<T>& v ) { bool first = true; os << "{"; for ( typename set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii ) { if( !first ) os << ","; os << *ii; first = false; } return os << "}"; }
template <typename T1, typename T2> inline ostream &operator << ( ostream & os, const map<T1, T2>& v ) { bool first = true; os << "{"; for ( typename map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii ) { if( !first ) os << ","; os << *ii ; first = false; } return os << "}"; }

template <typename T> void getarray( T a[], int b, int e ) { for( int i = b; i < e + b; i++ ) cin >> a[i]; }
template <typename T> void printarray( T a[], int b, int e ) { for( int i = b; i < e - 1 + b; i++ ) cout << a[i] << " "; if( e - 1 + b >= 0 ) cout << a[e - 1 + b] << endl; }
template <typename T> void printV( vector<T> v ) { int sz = v.size(); if( sz ) cout << v[0]; for( int i = 1; i < sz; i++ ) cout << " " << v[i]; nln; }

template <typename T> T gcd( T a, T b ) { if( b == 0 ) return a; return gcd( b, a % b ); }
template <typename T> T BigMod ( T b, T p, T m ) { if ( p == 0 ) return 1; if ( p % 2 == 0 ) { T s = BigMod( b, p / 2, m ); return ( ( s % m ) * ( s % m ) ) % m; } return ( ( b % m ) * ( BigMod( b, p - 1, m ) % m ) ) % m; }
template <typename T> T ModInv ( T b, T m ) { return BigMod( b, m - 2, m ); }

template<class T> inline void read( T &x ) { bool Minus = 0; char c; for( c = getchar(); c <= 32; c = getchar() ) ; if( c == '-' ) Minus = 1, c = getchar(); for( x = 0; c > 32; c = getchar() ) x = x * 10 + c - '0'; if( Minus ) x = -x; }
char getc() { char c; for( c = getchar(); c <= 32; c = getchar() ); return c; }  ///input char with buffering
int CI( int &_x ) { return scanf( "%d", &_x ); }
int CI( int &_x, int &_y ) { return scanf( "%d %d", &_x, &_y ); }
int CI( int &_x, int &_y, int &_z ) { return scanf( "%d %d %d", &_x, &_y, &_z ); }
int CI( int &_a, int &_b, int &_c, int &_d ) { return scanf( "%d %d %d %d", &_a, &_b, &_c, &_d ); }

template <class T> string toString( T n ) { ostringstream oss; oss << n; return oss.str(); }
int toInt( string s ) { int r = 0; istringstream sin( s ); sin >> r; return r; }
i64 toLong( string s ) { i64 r = 0; istringstream sin( s ); sin >> r; return r; }
bool isVowel( char ch ) { ch = tolower( ch ); if( ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' )return true; return false; }
bool isUpper( char c ) { return c >= 'A' && c <= 'Z'; }
bool isLower( char c ) { return c >= 'a' && c <= 'z'; }

int dr8[8] = { +1, -1, +0, +0, +1, -1, -1, +1};   ///8 direction move
int dc8[8] = { +0, +0, -1, +1, +1, +1, -1, -1};
int dr4[4] = { +0, +0, +1, -1};                   ///4 direction move
int dc4[4] = { -1, +1, +0, +0};                   ///or adjacent dir.
int kn8r[8] = { +1, +2, +2, +1, -1, -2, -2, -1};  ///knight moves
int kn8c[8] = { +2, +1, -1, -2, -2, -1, +1, +2};

const double EPS = 1e-9;                         ///constants
const int INF = ( 1 << 30 ) - 1;
const i64 LINF = ( 1ll << 62 ) - 1;
const int mod = ( int )1e9 + 7;
const int MAX = ( int )1e5;
///____________________________Main Coding Starts From Here________________________///

string rot1( string s ) {
    string t = s;
    t[0] = s[3];
    t[3] = s[1];
    t[1] = s[2];
    t[2] = s[0];
    return t;
}
string rot2( string s ) {
    string t = s;
    t[0] = s[4];
    t[4] = s[1];
    t[1] = s[5];
    t[5] = s[0];
    return t;
}
string rot3( string s ) {
    string t = s;
    t[4] = s[3];
    t[3] = s[5];
    t[5] = s[2];
    t[2] = s[4];
    return t;
}

map<string, int> marker;
set<string> res;

void MarkUpAll( string s ) {
    string s1 = s, s2, s3;
    for( int i = 0; i < 4; i++ ) {
        s2 = s1;
        for( int j = 0; j < 4; j++ ) {
            s3 = s2;
            for( int k = 0; k < 4; k++ ) {
                marker[s3] = 1;
                s3 = rot3( s3 );
            }
            s2 = rot2( s2 );
        }
        s1 = rot1( s1 );
    }
}

//int main2();

int main() {
#ifndef ONLINE_JUDGE
//    READ("in.txt");
//    WRITE("out.txt");
    deb_mode = 1;
#endif
    if( deb_mode )
        srand( int( time( NULL ) ) );

    int i, j, k, l, n, m, q, a, b, c;
    string s;
    cin >> s;
    sort(all(s));
    do {
        if( marker[s] == 0 ) {
            res.insert( s );
            MarkUpAll( s );
        }
    } while( next_permutation( all( s ) ) );

    cout << res.size() << "\n";

    //debug( res );nln;nln;

    if( deb_mode )
        cerr << "TIME = " << clock() << " ms" << endl;
    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define PI 3.14159265358979
#define MEMS(a,b) memset(a,b,sizeof(a))
#define LL long long
#define U unsigned
using namespace std;
string rotate(string s, int t)
{
	string res=s;
	if (t==0)
	{
		res[2]=s[5];
		res[3]=s[2];
		res[4]=s[3];
		res[5]=s[4];
	}
	if (t==1)
	{
		res[0]=s[5];
		res[3]=s[0];
		res[1]=s[3];
		res[5]=s[1];
	}
	if (t==2)
	{
		res[0]=s[2];
		res[4]=s[0];
		res[1]=s[4];
		res[2]=s[1];
	}
	return res;
}
set<string> s;
int main()
{
	string ss;
	cin>>ss;
	sort(ss.begin(),ss.end());
	int res=0;
	do
	{
		string sss=ss;
		if (s.find(ss)==s.end())
		{
			res++;
			FOR(i,0,4)
			{
				sss=rotate(sss,0);
				FOR(j,0,4)
				{
					sss=rotate(sss,1);
					FOR(k,0,4)
					{
						sss=rotate(sss,2);
						s.insert(sss);
					}
				}
			}
		}
	}while (next_permutation(ss.begin(),ss.end()));
	cout<<res<<endl;
	return 0;
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

char s[10];
char s1[7]="ROYGBV";
int main()
{
    int i,j,num[6];
    while(gets(s))
    {
        memset(num,0,sizeof(num));
        for(i=0;i<6;i++)
        {
            for(j=0;j<6;j++)
                if(s[i]==s1[j])
                    break;
            num[j]++;
        }
        sort(num,num+6);
        if(num[5]==6) printf("1\n");
        else if(num[5]==5)
            printf("1\n");
        else if(num[5]==4&&num[4]==2)
            printf("2\n");
        else if(num[5]==3&&num[4]==3)
            printf("2\n");
        else if(num[5]==4)
            printf("2\n");
        else if(num[5]==3&&num[4]==2)
            printf("3\n");
        else if(num[5]==2&&num[4]==2&&num[3]==2)
            printf("6\n");
        else if(num[5]==3)
            printf("5\n");
        else if(num[5]==2&&num[4]==2)
            printf("8\n");
        else if(num[5]==2)
            printf("15\n");
        else printf("30\n");
    }
    return 0;
}

#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <complex>
#include <stack>
#include <memory.h>
#ifdef NEV_DEBUG
#include <ctime>
#endif
using namespace std;
#pragma comment(linker,"/STACK:64000000")

const double pi = 3.1415926535897932384626433832795;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;

#define sz size()
#define mp make_pair
#define pb push_back
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a),_b(b); i<_b; ++i)
#define RFOR(i,a,b) for(int i=(a)-1,_b(b); i>=_b; --i)
#define CLR(a,b) memset(a,b,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(a) ((a)*(a))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))

char ch[1<<20];
string gs() {scanf("%s",ch); return string(ch);}
string gl() {gets(ch); return string(ch);}
template <class T>
T gcd(T a, T b) { return (!a)?b:gcd(b%a,a); }
void error(){ int yyy=0; cout << 7/yyy; }

int g[][6] = {
	{0,1,2,3,4,5},
	{1,5,2,0,4,3},
	{2,5,3,0,1,4},
	{5,4,3,2,1,0},
	{3,4,0,2,5,1},
	{4,1,0,3,5,2}
};

int main() {

#ifdef NEV_DEBUG
    freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	//freopen("in.txt","w",stdout); printf("1000000\n"); /*FOR(i,0,1000000) printf("%d ",1+i); printf("\n");*/ exit(0);
    clock_t beg = clock();
#else
    //freopen("union.in","r",stdin);
    //freopen("union.out","w",stdout);
#endif
	string s=gs();
	sort(ALL(s));
	set<string> was;
	int r=0;
	do {
		if (!was.count(s)) {
			FOR(i,0,6) {
				FOR(j,0,4) {
					string v;
					v+=s[g[i][0]];
					FOR(k,0,4) v+=s[g[i][1+(j+k)%4]];
					v+=s[g[i][5]];
					was.insert(v);
				}
			}
			++r;
		}
	} while(next_permutation(ALL(s)));
	cout << r << endl;

#ifdef NEV_DEBUG
    fprintf(stderr,"*** Total time: %.3lf ***\n",1.0*(clock()-beg)/CLOCKS_PER_SEC);
#endif
    return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<cstdio>
#include<math.h>
#include<cstdlib>
#include<map>
#include<utility>
#include<stack>
#include<fstream>
#include<set>

using namespace std;
#define ll long long int
vector <ll> v;
vector <ll> v1;
vector <ll> v2;
const ll inf=100000000000005;

#define cincout ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define me1(a,i) memset(a,i,sizeof(a))
#define me2(a,i,n,m) memset(a,i,n*m*sizeof(a[0][0]))
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(),v.end())
#define printv(n,v) for(int i=0;i<n;i++)  {cout<<v[i]<<" ";}
#define vin(v,n,a) for(int i=0;i<n;i++)	{v.pb(a);cin>>v[i];}

set<string>all;
void rot(string s)
	{
	if(all.find(s)!=all.end())
		return;
	all.insert(s);
	char s1[]={s[1],s[2],s[3],s[0],s[4],s[5],0};
	rot(s1);
	char s2[]={s[0],s[4],s[2],s[5],s[3],s[1],0};
	rot(s2);
	}
int main()
	{
	int ans=0;
	char s[10];
	cin>>s;
	sort(s,s+6);
	do
		{
		if(all.find(s)!=all.end())
			continue;
		ans++;
		rot(s);
		}while(next_permutation(s,s+6));
	cout<<ans<<endl;
	return 0;
	}

#include <bits/stdc++.h>

using namespace std;
typedef vector<int> vi;

int main(){
	vi arr(6,0);
	for(int i=0;i<6;i++){
		char c;
		cin>>c;
		if(c=='R') arr[0]++;
		else if(c=='O') arr[1]++;
		else if(c=='Y') arr[2]++;
		else if(c=='G') arr[3]++;
		else if(c=='B') arr[4]++;
		else if(c=='V') arr[5]++;
	}
	sort(arr.begin(), arr.end());
	int ans = 0;
	if(arr[5]==6) ans = 1;

	else if(arr[5]==5) ans = 1;

	else if(arr[5]==4 && arr[4]==2) ans = 2;
	else if(arr[5]==4 && arr[4]==1) ans = 2;

	else if(arr[5]==3 && arr[4]==3) ans = 2;
	else if(arr[5]==3 && arr[4]==2) ans = 3;
	else if(arr[5]==3 && arr[4]==1) ans = 5;

	else if(arr[5]==2 && arr[4]==2 && arr[3]==2) ans = 6;
	else if(arr[5]==2 && arr[4]==2 && arr[3]==1) ans = 8;
	else if(arr[5]==2 && arr[4]==1) ans = 15;

	else if(arr[5]==1) ans = 30;
	cout<<ans<<endl;

}

#include <bits/stdc++.h>

#define pb push_back
#define pp pop_back
#define mp make_pair
#define ld long double
#define f first
#define s second
#define ll long long

using namespace std;

const int N = 1e5 + 5;

const int mod = 1e9 + 7;

string a;

map < string, bool > used;

int ans;

void shift(string &nw, int i, int j)
{
	nw = nw.substr(i + 1, j - i) + nw[0] + nw.substr(j + 1);
}

void goo(string a)
{
	string nw = a;
	used[nw] = 1;
	nw[0] = a[5];
	nw[2] = a[4];
	nw[4] = a[0];
	nw[5] = a[2];
	for (int i = 0;i < 4;i++)
	{
 		used[nw] = 1;
 		shift(nw, 0, 3);
	}
	nw[0] = a[2];
	nw[2] = a[0];
	nw[4] = a[5];
	nw[5] = a[4];
	for (int i = 0;i < 4;i++)
	{
		used[nw] = 1;
		shift(nw, 0, 3);
	}
	nw[0] = a[4];
	nw[2] = a[5];
	nw[4] = a[2];
	nw[5] = a[0];
	for (int i = 0;i < 4;i++)
	{
		used[nw] = 1;
		shift(nw, 0, 3);
	}
}

void go(string a)
{
	string nw = a;
	goo(nw);
	shift(nw, 0, 3);
	goo(nw);
	shift(nw, 0, 3);
	goo(nw);
	shift(nw, 0, 3);
	goo(nw);
}

int main()
{
  ios_base::sync_with_stdio(0);
  cin >> a;
  sort(a.begin(), a.end());
 	do
 	{
 		if (!used[a])
 		{
// 		  cout << "new a = " << a << endl;
 			ans++;
 			go(a);
 		}
 	} while(next_permutation(a.begin(), a.end()));
 	cout << ans;
	return 0;
}

#include<stdio.h>
#include<string.h>
int flag[6],total;
char l[100][7],list[7],str[7];
int  f2(int a,int b,int c,int d,int e,int f)
{
        int i;
        a--;
        b--;
        c--;
        d--;
        e--;
        f--;
        char cur[100];
        cur[6]='\0';
        cur[0]=list[a];
        cur[1]=list[b];
        cur[2]=list[c];
        cur[3]=list[d];
        cur[4]=list[e];
        cur[5]=list[f];
        for(i=0;i<total;i++)
        {
                if(strcmp(cur,l[i])==0)
                        return 1;
        }

        cur[2]=list[d];
        cur[3]=list[e];
        cur[4]=list[f];
        cur[5]=list[c];

        for(i=0;i<total;i++)
        {
                if(strcmp(cur,l[i])==0)
                        return 1;
        }
        cur[2]=list[e];
        cur[3]=list[f];
        cur[4]=list[c];
        cur[5]=list[d];

        for(i=0;i<total;i++)
        {
                if(strcmp(cur,l[i])==0)
                        return 1;
        }

        cur[2]=list[f];
        cur[3]=list[c];
        cur[4]=list[d];
        cur[5]=list[e];

        for(i=0;i<total;i++)
        {
                if(strcmp(cur,l[i])==0)
                        return 1;
        }
        return 0;
}
void f(int x)
{
        int yes;
        int i;
        if(x==6)
        {
		//total++;
                list[x]='\0';
                //printf("%s\n",list);
                //return;
                yes=0;
                yes+=f2(1,2,3,4,5,6);
                if(yes)
                        return;
                yes+=f2(2,1,5,4,3,6);

                if(yes)
                        return;
                yes+=f2(3,5,2,4,1,6);

                if(yes)
                        return;
                yes+=f2(5,3,1,4,2,6);
                if(yes)
                        return;
                yes+=f2(4,6,3,2,5,1);
                yes+=f2(6,4,3,1,5,2);
                if(yes)
                        return;
                yes+=f2(6,4,5,1,3,2);
                if(yes==0)
                        strcpy(l[total++],list);
                return;
        }
        for(i=0;i<6;i++)
        {
                if(flag[i]==0)
                {
                        flag[i]=1;
                        list[x]=str[i];
                        f(x+1);
                        flag[i]=0;
                }

        }
}
int main()
{
        int i;
        while(scanf("%s",str)!=EOF)
        {
                total=0;
                for(i=0;i<6;i++)
                        flag[i]=0;
                f(0);
                printf("%d\n",total);
        }
        return 0;
}

#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

vector<vector<int>> v;
string s;
set<vector<int>> mp;
vector<int> rot = {0,4,2,5,3,1};

vector<int> hor(vector<int> a){
  fore(i,1,4) swap(a[i],a[i-1]);
  return a;
}

vector<int> ver(vector<int> a){
  vector<int> ans;
  fore(i,0,6) ans.pb(a[rot[i]]);
  return ans;
}

void dfs(vector<int> a){
  if(mp.find(a) != mp.end()) return;
  v.pb(a);
  mp.insert(a);
  dfs(hor(a));
  dfs(ver(a));
}

set<string> ans;

int main(){FIN;
  cin >> s;
  sort(ALL(s));
  dfs({0,1,2,3,4,5});
  do{
    int can = 1;
    fore(i,0,SZ(v)){
      string now = "";
      fore(j,0,6) now += s[v[i][j]];
      if(ans.find(now) != ans.end()){
        can = 0;
        break;
      }
    }
    if(can){
      ans.insert(s);
    }
  }while(next_permutation(ALL(s)));
  cout << ans.size() << endl;
}

/**Bismillahir Rahmanir Rahim//fold
 * @note
 */
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000007
#define llinf 1000000000000000000LL
#define bug(args ...) { cout<<__LINE__<<": "; string s = #args; istringstream ss(s); err(ss, args); cout<<"\n"; }
void err(istringstream &ss) {}
template<typename T, typename ... Args> void err(istringstream &ss, const T &varVal, const Args & ... args) {
    string varName; getline(ss, varName, ',');
    cout << varName << " = " << varVal << "; ", err(ss, args ...);
}
typedef long long int ll; typedef unsigned long long int ull;   // typedef long double ld;
int n, m, T, Q, sz, len, cn = 0;//end
#define MAXN 200005

string topToFront(const string &s) {  //T -> F, F -> D, D -> B, B -> T
    string ret = s;
    ret[2] = s[0], ret[1] = s[2], ret[4] = s[1], ret[0] = s[4];
    return ret;
}

string leftToFront(const string &s) {  //L -> F, F -> R, R -> B, B -> L
    string ret = s;
    ret[2] = s[5], ret[3] = s[2], ret[4] = s[3], ret[5] = s[4];
    return ret;
}

string leftToTop(const string &s) { //L -> T, T -> R, R -> D, D -> L
    string ret = s;
    ret[0] = s[5], ret[3] = s[0], ret[1] = s[3], ret[5] = s[1];
    return ret;
}

string getMin(string s) {
    string mn = s;
    for (int i = 0; i < 6; i++) {
        if (i<4) s = topToFront(s);
        else if (i==4) s = leftToTop(s); // making left as top
        else if (i==5) {
            for (int j = 0; j < 2; j++) {
                s = leftToTop(s);   // making right as top
            }
        }
        string r = s;
        for (int j = 0; j < 4; j++) {
            r = leftToFront(r);
            mn = min(mn, r);
        }
    }
    return mn;
}

int main() {
    cin.tie(NULL);
    cout.tie(NULL);

    // seen solution :'( from http://codeforces.com/blog/entry/2323?#comment-49182
    string str;
    cin >> str;
    sort(str.begin(), str.end());
    set<string> s;
    // getMin("TDFRBL");
    do {
        s.insert(getMin(str));  // Top, Down, Front, Right, Back, Left
    } while (next_permutation(str.begin(), str.end()));
    printf("%lu\n", s.size());

    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

string turn_r(string s)
{
	string t=s;
	char c=t[0];t[0]=t[2];t[2]=t[3];t[3]=t[5];t[5]=c;
	return t;
}
string turn_u(string s)
{
	string t=s;
	char c=t[1];t[1]=t[5];t[5]=t[4];t[4]=t[2];t[2]=c;
	return t;
}
string turn_f(string s)
{
	string t=s;
	char c=t[0];t[0]=t[4];t[4]=t[3];t[3]=t[1];t[1]=c;
	return t;
}

string f(string s)
{
	string result=s;
	string t=s;
	rep(i,6){
		t=i&1?turn_r(t):turn_f(t);
		rep(j,4){
			t=turn_u(t);
			result=min(result,t);
		}
	}
	return result;
}

int main()
{
	for(string s;cin>>s && s!="#";){
		set<string> res;
		sort(allof(s));
		do{
			res.insert(f(s));
		}while(next_permutation(allof(s)));
		cout<<res.size()<<endl;
	}

	return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

#define MP make_pair
#define VI vector<int>
#define PI 3.14159265358979
#define LL long long
using namespace std;

set<string> ss;
string str;

void r1( string &s )
{
	char t = s[0]; s[0] = s[1], s[1] = s[2], s[2] = s[3], s[3] = t;
}

void r2( string &s )
{
	char t = s[1]; s[1] = s[4], s[4] = s[3], s[3] = s[5], s[5] = t;
}

void r3( string &s )
{
	char t = s[0]; s[0] = s[4], s[4] = s[2], s[2] = s[5], s[5] = t;
}

void check( string s )
{
	string best = s;
	for( int i = 0; i < 4; ++ i )
	{
		r1( s );
		if( best > s ) best = s;
		for( int j = 0; j < 4; ++ j )
		{
			r2( s );
			if( best > s ) best = s;
			for( int k = 0; k < 4; ++ k )
			{
				r3( s );
				if( best > s ) best = s;
			}
		}
	}
	ss.insert( best );
}

int main()
{
	//freopen ( "in.txt", "r", stdin );
	//freopen ( "out.txt", "w", stdout );
	string str;
	while( cin >> str )
	{
		ss.clear();
		sort( str.begin(), str.end() );
		do
		{
			check( str );
		}while( next_permutation( str.begin(), str.end() ) );
		printf( "%d\n", ss.size() );
	}

	return 0;
}

#include <iostream>
#include <string>
#include <set>
using namespace std;
string s,w; set<string> q;
bool used[6];
void build(int cur)
{
 if (cur==6)
 {
  bool yes=false;
  for (set<string>::iterator it=q.begin();it!=q.end() && !yes;++it)
  {
   string p=*it;
   for (int i=0;i<6 && !yes;++i)
    if (p[i]==w[0])
    {
     switch (i)
     {
      case 1: swap(p[3],p[5]); swap(p[0],p[1]); break;
      case 2: swap(p[2],p[1]); swap(p[1],p[4]); swap(p[4],p[0]); break;
      case 3: swap(p[3],p[1]); swap(p[1],p[5]); swap(p[5],p[0]); break;
      case 4: swap(p[4],p[1]); swap(p[1],p[2]); swap(p[2],p[0]); break;
      case 5: swap(p[5],p[1]); swap(p[1],p[3]); swap(p[3],p[0]); break;
     }
     if (p[1]==w[1])
      for (int j=0;j<4;++j)
      {
       swap(p[2],p[3]); swap(p[3],p[4]); swap(p[4],p[5]);
       if (w==p) { yes=true; break; }
      }
     p=*it;
    }
  }
  if (!yes) q.insert(w);
 }
 for (int i=0;i<6;++i)
  if (!used[i])
  {
   used[i]=true;
   w[cur]=s[i];
   build(cur+1);
   used[i]=false;
  }
}
int main()
{
 cin>>s; w.resize(6);
 build(0);
 cout<<q.size();
}

#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;

#define li              unsigned long long
#define rep(i,to)       for(li i=0;i<((li)to);i++)
#define pb              push_back
#define sz(v)           ((li)v.size())
#define mp(x,y)         make_pair(x, y)

typedef vector<char> vc;

int main(){
  vc gems;
  set<vc> id, tr, trr, trs, trrs;
  for(int i=0;i<6;i++){
    char c;
    cin >> c;
    gems.pb(c);
  }

  sort(gems.begin(), gems.end());

  do{
    id.insert(gems);
    if(gems[1] == gems[2] && gems[1] == gems[3] && gems[1] == gems[4]) tr.insert(gems);
    if(gems[1] == gems[3] && gems[2] == gems[4]) trr.insert(gems);
    if(gems[1] == gems[2] && gems[1] == gems[3] && gems[4] == gems[5] && gems[4] == gems[0]) trs.insert(gems);
    if(gems[1] == gems[2] && gems[3] == gems[4] && gems[5] == gems[0]) trrs.insert(gems);
  }while(next_permutation(gems.begin(), gems.end()));

  cout << (sz(id) + 6 * sz(tr) + 3 * sz(trr) + 8 * sz(trs) + 6 * sz(trrs)) / 24 << endl;

  return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define mod 1000000007
#define LL long long

int a[6];

int main()
{
    map<char,int> mp;
    mp['R'] = 0;
    mp['O'] = 1;
    mp['Y'] = 2;
    mp['G'] = 3;
    mp['B'] = 4;
    mp['V'] = 5;

    char str[7];
    cin>>str;
    for(int i=0;i<6;i++)
        a[mp[str[i]]]++;
    sort(a,a+6);
    reverse(a,a+6);

    int s;
    if(a[0]>=5)
        s = 1;
    else if(a[0]==4)
        s = 2;
    else if(a[1]==3)
        s = 2;
    else if(a[0]==3 && a[1]==2)
        s = 3;
    else if(a[0]==3)
        s = 5;
    else if(a[2]==2)
        s = 6;
    else if(a[1]==2)
        s = 8;
    else if(a[0]==2)
        s = 15;
    else
        s = 30;
    cout<<s;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <ctime>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>

#define MOD 1000000007
#define inf 0x3f3f3f3f
#define INF -0x3f3f3f3f
#define ll long long
#define PI acos(-1.0)
#define eps 1e-6

#define mem0(x) memset((x),0,sizeof(x))
using namespace std;

int dir1[8][2] = {1,2,2,1,2,-1,1,-2,-1,2,-2,1,-1,-2,-2,-1};

int dir2[4][2] = {1,0,0,1,-1,0,0,-1};

int dir3[8][2] = {1,0,0,1,-1,0,0,-1,1,1,1,-1,-1,1,-1,-1};

int gcd(int x , int y)
{
    return y == 0 ? x : gcd(y , x % y);
}

bool Isleap(int year)
{
    if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
        return true;
    return false;
}

bool isPrime(int x)
{
    if(x == 1)
        return false;
    else if(x == 2)
        return true;
    for(int i = 2; i <= sqrt(x * 1.0); ++i)
    {
        if(x % i == 0)
            return false;
    }
    return true;
}

int sqr(int x)
{
    return x * x;
}

int main()
{
    #ifdef LOCAL_TEST
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    string s;
    while(cin >> s)
    {
        int sum[10] = {0};
        for(int i = 0; i < s.size(); ++i)
        {
            if(s[i] == 'R')
                sum[0] ++;
            if(s[i] == 'O')
                sum[1] ++;
            if(s[i] == 'Y')
                sum[2] ++;
            if(s[i] == 'G')
                sum[3] ++;
            if(s[i] == 'B')
                sum[4] ++;
            if(s[i] == 'V')
                sum[5] ++;
        }
        sort(sum,sum + 6);
        if(sum[5] == 6)
            printf("1\n");
        else if(sum[5] == 5)
            printf("1\n");
        else if(sum[5] == 4)
            printf("2\n");
        else if(sum[5] == 3)
        {
            if(sum[4] == 3)
                printf("2\n");
            else if(sum[4] == 2)
                printf("3\n");
            else if(sum[4] == 1)
                printf("5\n");
        }
        else if(sum[5] == 2)
        {
            if(sum[4] == 2 && sum[3] == 2)
                printf("6\n");
            else if(sum[4] == 2 && sum[3] == 1)
                printf("8\n");
            else if(sum[4] == 1)
                printf("15\n");
        }
        else if(sum[5] == 1)
            printf("30\n");
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define debug(x) cerr << "  - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << "  - " << #x << ": " << x << "         " << #y << ": " << y << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

typedef long long ll;
const ll mod = 1e9 + 7;

map <vector <char>, int> m;

vector <char> rotz(vector <char> v) {
	char tmp = v[3];
	v[3] = v[2], v[2] = v[1], v[1] = v[0], v[0] = tmp;
	return v;
}

vector <char> roty(vector <char> v) {
	swap(v[4], v[0]);
	swap(v[4], v[2]);
	swap(v[2], v[5]);
	return v;
}

vector <char> rotx(vector <char> v) {
	swap(v[5], v[1]);
	swap(v[5], v[3]);
	swap(v[3], v[4]);
	return v;
}

bool go(vector <char> v) {
	for(int i = 0; i < 4; i++) {
		for(int j = 0; j < 4; j++) {
			for(int k = 0; k < 4; k++) {
				v = rotz(v);
				if(m.find(v) != m.end()) return true;
			}
			v = roty(v);
		}
		v = rotx(v);
	}
	return false;
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	vector <char> v;
	for(int i = 0; i < sz(s); i++) v.pb(s[i]);
	sort(all(v));
	int cnt = 0;
	do {
		if(!go(v)) {
			m[v] = 1;
			cnt++;
		}
	}while(next_permutation(all(v)));
	cout << cnt << endl;
	return 0;
}

#include <bits/stdc++.h>

#define MAXN 10

using namespace std;

struct state {
    string a;
};

state init;
set <string> ans, sol;

/*
 3
 2
514
 0
*/

state rotate_horiz( state tmp ) {
    /*
     3      5
     2      2
    514 => 143
     0      0
    */
    state ret = tmp;
    ret.a[1] = tmp.a[4];
    ret.a[3] = tmp.a[5];
    ret.a[4] = tmp.a[3];
    ret.a[5] = tmp.a[1];
    return ( ret );
}

state rotate_vert( state tmp ) {
    /*
     3      2
     2      1
    514 => 504
     0      3
    */
    state ret = tmp;
    for ( int i = 0; i < 4; ++i ) {
        ret.a[i] = tmp.a[(i+1)%4];
    }
    return ( ret );
}

void solve( state tmp ) {

    if ( sol.find( tmp.a ) != sol.end() ) {
        return;
    }

    sol.insert( tmp.a );

    solve( rotate_horiz(tmp) );
    solve( rotate_vert( tmp ) );

}

int main( ) {

    cin >> init.a;

    sort( init.a.begin(), init.a.end() );

    do {
        sol.clear();
        solve( init );
        /*
        for ( auto c : sol ) {
            cout << c << endl;
        }
        cout << "-\n";*/
        if ( ans.find( *sol.begin() ) == ans.end() ) {
            ans.insert( *sol.begin() );
        }
    }while ( next_permutation( init.a.begin(), init.a.end() ) );

    printf( "%d\n", (int)ans.size() );

    return 0;

}

/*
PROG: butter
ID: ali.mas1
LANG: C++
*/
#include "iostream"
#include "cstdio"
#include "algorithm"
#include "string"
#include "vector"
#include "cstdlib"
#include "cmath"
#include "fstream"
#include "iomanip"
#include "list"
#include "deque"
#include "map"
#include "sstream"
#include "numeric"
#include "stack"
#include "queue"
#include "set"
#include "ctime"
#include "cstring"
#include "complex"

using namespace std;

#define clr(a,b) memset(a, b, sizeof(a))
#define cpy(a, b) memcpy(a, b, sizeof(b))
#define sz(a) ((int)a.size())

typedef long long ll;
typedef pair<int, int> pi;
typedef complex<double> point;

const double eps = 1e-8;
const int MAX_N = 1000;
const int inf=(int)(1e9);

string s = "";
set <string> S;
int used[10];

int x[] = {4, 5, 2, 3, 1, 0};
int y[] = {0, 1, 5, 4, 2, 3};
int z[] = {2, 3, 1, 0, 4, 5};

void rotate(string &cur, int a[]){
	string aux = cur;
	for(int i = 0; i < 6; i++){
		cur[i] = aux[a[i]];
	}
}

void check(string cur){
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 4; j++){
			for(int k = 0; k < 4; k++){
				if(S.find(cur) != S.end()) return;
				rotate(cur, z);
			}
			rotate(cur, y);
		}
		rotate(cur, x);
	}
	S.insert(cur);
}

void rec(int depth, string cur){
	if(depth == 6){check(cur); return;}
	for(int i = 0; i < 6; i++){
		if(used[i] == 0){
			used[i] = 1;
			rec(depth + 1, cur + s[i]);
			used[i] = 0;
		}
	}
}

int main(){
	//freopen("in.in", "r", stdin);
	cin >> s; sort(s.begin(), s.end());
	string cur = "";
	rec(0, cur);
	cout << sz(S) << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define For(i, n) for (int i = 0; i < int(n); i++)
#define ForD(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define SORT(x) sort(begin(x), end(x))
#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

template<typename T, typename U>
pair<T, U>& operator+=(pair<T, U> &lhs, const pair<T, U> &rhs){
	lhs.first += rhs.first;
	lhs.second += rhs.second;
	return lhs;
}

template<typename T, typename U>
pair<T, U>& operator-=(pair<T, U> &lhs, const pair<T, U> &rhs){
	lhs.first -= rhs.first;
	lhs.second -= rhs.second;
	return lhs;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &container) {
	for (auto &u : container) os << u << " ";
	return os;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << p.first << " " << p.second;
	return os;
}

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using pb_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#if DEBUG
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
#else
#define error(...) do {} while (0)
#endif

template<typename T, typename U>
pair<T, U> operator-(const pair<T, U> &l, const pair<T, U> &r) {
	return {l.first - r.first, l.second - r.second};
}
template<typename T, typename U>
pair<T, U> operator+(const pair<T, U> &l, const pair<T, U> &r) {
	return {l.first + r.first, l.second + r.second};
}

#define _upgrade do { ios::sync_with_stdio(0); cin.tie(0); } while (0)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

set<string> all_reps;

int rot_arr[3][6] = {
    {3, 1, 2, 5, 0, 4},
    {2, 0, 5, 3, 4, 1},
    {0, 4, 3, 1, 2, 5}
};

string rot(string s, int r) {
    string res(6, 0);
    For (i, 6) res[rot_arr[r][i]] = s[i];

    return res;
}

void smallest_rot(set<string> &res, string s, int r) {
    res.insert(s);
    if (r > 2) return;

    For (i, 4) {
        s = rot(s, r);
        smallest_rot(res, s, r + 1);
    }
}

int main() {
	_upgrade;

    string s;
    cin >> s;

    sort(s.begin(), s.end());

    do {
        set<string> rots;
        smallest_rot(rots, s, 0);
        all_reps.insert(*rots.begin());
    } while (next_permutation(s.begin(), s.end()));

    cout << all_reps.size() << "\n";
}

#include<iostream>
#include<vector>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<cstdlib>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<queue>
#include<cassert>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pi;
typedef long long ll;

const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

string rotx(string s){
	string t=s;
	t[1]=s[4]; t[2]=s[1]; t[3]=s[2]; t[4]=s[3];
	return t;
}
string roty(string s){
	string t=s;
	t[0]=s[1]; t[1]=s[5]; t[3]=s[0]; t[5]=s[3];
	return t;
}
string rotz(string s){
	string t=s;
	t[0]=s[2]; t[2]=s[5]; t[4]=s[0]; t[5]=s[4];
	return t;
}

int ans;
set<string> S;
string s; bool use[6];

void dfs(string cur){
	bool f=1;
	rep(i,6)if(!use[i]){
		f=0;
		use[i]=1;
		cur.pb(s[i]);
		dfs(cur);
		cur.erase(cur.end()-1);
		use[i]=0;
	}
	if(f){
		rep(i,64){
			string t=cur;
			rep(j,i%4){
				t=rotx(t); if(S.count(t))return;
			}
			rep(j,i/4%4){
				t=roty(t); if(S.count(t))return;
			}
			rep(j,i/16%4){
				t=rotz(t); if(S.count(t))return;
			}
		}
		ans++;
		rep(i,64){
			string t=cur;
			rep(j,i%4){
				t=rotx(t); S.insert(t);
			}
			rep(j,i/4%4){
				t=roty(t); S.insert(t);
			}
			rep(j,i/16%4){
				t=rotz(t); S.insert(t);
			}
		}
	}
}

void run()
{
	cin>>s;
	rep(i,6)use[i]=0; S.clear();
	ans=0;
	dfs("");

	cout<<ans<<endl;
}

int main()
{
	//int cs=3;rep(i,cs)
	run();
}

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int cnt = 0;
set <string> ans;

void do_cycle(string s)
{
     for (int i = 0;i < 4; ++i){
         //cout << s << endl;
         if (ans.find(s) != ans.end())
            ans.erase(ans.find(s));
         char c = s[3];
         s[3] = s[2];
         s[2] = s[1];
         s[1] = s[0];
         s[0] = c;
     }
}

int main(){
    string s, ss = "xxxxxx", ns = "xxxxxx";
    string rot[3] = {"012345", "042531", "415320"};
    cin >> s;
    int in[6] = {0, 1, 2, 3, 4, 5}, c = 0;
    do{
       ++c;
       for (int i = 0;i < 6;++i)
           ns[i] = s[in[i]];
       for (int i = 0;i < 3;++i){
           for (int j = 0;j < 6;++j)
               ss[j] = ns[rot[i][j] - '0'];
           do_cycle(ss);
           swap(ss[4], ss[5]);
           swap(ss[1], ss[3]);
           do_cycle(ss);
       }
       ans.insert(ns);
    }
    while (next_permutation(in, in + 6));
    cout << ans.size() << endl;
    cin >> s;
    return 0;
}

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
void pan(int x,int y,int z);
int main()
{
    char color[7];//////////////   6/7??
    cin>>color;
    int num=0,i;
    int count1=0,count2=0,count3=0,count4=0,count5=0,count6=0;
    for(i=0;i<6;i++)
    {
        if(color[i]=='R')count1++;
        if(color[i]=='O')count2++;
        if(color[i]=='Y')count3++;
        if(color[i]=='G')count4++;
        if(color[i]=='B')count5++;
        if(color[i]=='V')count6++;
    }
    int count[6]={count1,count2,count3,count4,count5,count6};
    sort(count,count+6);
    pan(count[5],count[4],count[3]);
    return 0;
}
void pan(int x,int y,int z)
{
    if(x==1&&y==1&&z==1)
        cout<<30<<endl;
    else if(x==2&&y==1&&z==1)
        cout<<15<<endl;
    else if(x==3&&y==1&&z==1)
        cout<<5<<endl;
    else if(x==4&&y==1&&z==1)
       cout<<2<<endl;
    else if(x==5&&y==1)
        cout<<1<<endl;
    else if(x==6&&y==0)
        cout<<1<<endl;
    else if(x==2&&y==2&&z==1)
        cout<<8<<endl;
    else if(x==2&&y==2&&z==2)
       cout<<6<<endl;
    else if(x==3&&y==2)
        cout<<3<<endl;
    else if(x==4&&y==2)
        cout<<2<<endl;
    else if(x==3&&y==3)
        cout<<2<<endl;
}

#include <assert.h>
#include <ctype.h>
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
#include <iostream>
#include <memory.h>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define clr(a,b) memset(a,b,sizeof(a));
#define all(c) (c).begin(), (c).end()
#define inf 1000000000

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<string> vs;
typedef vector<int> vi;

char s[10];
map<string, int> mc;

void rotate(string s, int c)
{
    if (mc.find(s) != mc.end())
        return;
    mc[s] = c;

    string n = s;
    n[0] = s[1];
    n[1] = s[2];
    n[2] = s[3];
    n[3] = s[0];

    rotate(n, c);

    n = s;
    n[1] = s[5];
    n[5] = s[3];
    n[3] = s[4];
    n[4] = s[1];
    rotate(n, c);

}

int main(int argc, char* argv[])
{
#ifndef ONLINE_JUDGE
    freopen("test.in", "r", stdin);
#endif
    scanf("%s", &s);

    sort(s, s + 6);
    int c = 0;

    do
    {
        if (mc.find(s) == mc.end())
        {
            rotate(string(s), c);
            c++;
        }
    }
    while(next_permutation(s, s + 6));

    cout << c;

    return 0;
}

#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

const int INF = 2000000000;

typedef long double ld;

const int f[3][8] = {{0,1,3,5,0,1,3,5},{0,2,3,4,0,2,3,4},{2,1,4,5,2,1,4,5}};

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int ans = 0;
    string a;
    cin >> a;

    set<string> d;
    sort(a.begin(),a.end());
    do
    {
        if (d.count(a) > 0) continue;
        ans++;
        for (int i = 0; i < 3; i++)
        for (int ii = 0; ii < 3; ii++)
        for (int j = 0; j < 4; j++)
        for (int jj = 0; jj < 4; jj++)

            {
                string n0 = a;
                for (int k = 0; k < 4; k++)
                    n0[f[i][k]] = a[f[i][k+j]];
                string n = n0;
                for (int k = 0; k < 4; k++)
                    n[f[ii][k]] = n0[f[ii][k+jj]];
                d.insert(n);
            }

    } while(next_permutation(a.begin(),a.end()));

    cout << ans;

}

using namespace std;
#include<string.h>
#include <sstream>
typedef long long int ll;
typedef long double ld;
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <map>
//#define N 4
//const ll INF = 0x3f3f3f3f;
//const ll INF = 0x3f3f3f3f3f3f3f3f;
#include <queue>
#include <unordered_set>
#include <math.h>
#include <cstring>
#include <bitset>
#include <numeric>
#include <set>
#include <stack>
#include <sstream>
#include <list>
#include <queue>
#include <sstream>
#define PI 3.14159265358979323846264338327950
#define mp make_pair
#define inf 1e9
#define endl '\n'
//#define M 1000000007
//#define N 1000000

void rotate(string &s) {

	char t = s[2];
	s[2] = s[3];
	s[3] = s[4];
	s[4] = s[5];
	s[5] = t;
}

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	string s;
	cin >> s;

	map<string, int> map;

	sort(s.begin(), s.end());

	int ans = 0;
	do {

		if (map[s]) {
			continue;
		}
		ans++;

		string t = s;

		t[0] = s[0];
		t[1] = s[1];
		t[2] = s[2];
		t[3] = s[3];
		t[4] = s[4];
		t[5] = s[5];

		for (int i = 0; i < 4; i++) {
			rotate(t);
			map[t] = 1;
		}

		t[0] = s[1];
		t[1] = s[0];
		t[2] = s[4];
		t[3] = s[3];
		t[4] = s[2];
		t[5] = s[5];

		for (int i = 0; i < 4; i++) {
			rotate(t);
			map[t] = 1;
		}

		t[0] = s[2];
		t[1] = s[4];
		t[2] = s[1];
		t[3] = s[3];
		t[4] = s[0];
		t[5] = s[5];

		for (int i = 0; i < 4; i++) {
			rotate(t);
			map[t] = 1;
		}

		t[0] = s[4];
		t[1] = s[2];
		t[2] = s[0];
		t[3] = s[3];
		t[4] = s[1];
		t[5] = s[5];

		for (int i = 0; i < 4; i++) {
			rotate(t);
			map[t] = 1;
		}

		t[0] = s[3];
		t[1] = s[5];
		t[2] = s[2];
		t[3] = s[1];
		t[4] = s[4];
		t[5] = s[0];

		for (int i = 0; i < 4; i++) {
			rotate(t);
			map[t] = 1;
		}

		t[0] = s[5];
		t[1] = s[3];
		t[2] = s[2];
		t[3] = s[0];
		t[4] = s[4];
		t[5] = s[1];

		for (int i = 0; i < 4; i++) {
			rotate(t);
			map[t] = 1;
		}

	} while (next_permutation(s.begin(), s.end()));

	cout << ans << endl;
}

#include <iostream>
#include <cstdio>
#include <set>
#include <algorithm>

using namespace std;

char col[6];

struct node{

    char a[6];

    node () {}

    node (char *v) { for (int i=0; i<6; i++) a[i]=v[i]; }

    node (char x1 , char x2 , char x3 , char x4 , char x5 , char x6){
        a[0]=x1; a[1]=x2; a[2]=x3;
        a[3]=x4; a[4]=x5; a[5]=x6;
    }

    inline bool operator < (const node &sec) const{

        for (int i=0; i<6; i++) if (a[i]!=sec.a[i]) return a[i]<sec.a[i];

        return false;
    }

    inline void rotate (){
        swap (a[2],a[5]);
        swap (a[2],a[3]);
        swap (a[2],a[4]);
    }
};

int main(){

    for (int i=0; i<6; i++) cin >> col[i];

    sort (col , col+6);

    set <node> sit;

    do{

        node t[6];

        t[0]= node(col[0],col[1], col[2],col[3], col[4],col[5]);
        t[1]= node(col[1],col[0], col[3],col[2], col[4],col[5]);
        t[2]= node(col[2],col[3], col[1],col[0], col[4],col[5]);
        t[3]= node(col[3],col[2], col[0],col[1], col[4],col[5]);
        t[4]= node(col[4],col[5], col[1],col[0], col[3],col[2]);
        t[5]= node(col[5],col[4], col[0],col[1], col[3],col[2]);

        bool flag = false;

        for (int i=0; (!flag) && i<6; i++){

            for (int j=0; (!flag) && j<4;j++){
                t[i].rotate();
                if (sit.find(t[i])!=sit.end())
                    flag = true;
            }
        }

        if (!flag)
            sit.insert (node(col));

    }while (next_permutation(col,col+6));

    cout << sit.size() << endl;

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <ctime>
#include <algorithm>
#include <set>

#define EPS 1E-8
#define sqr(o) ((o)*(o))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))

using namespace std;

int v[1000][6];
int mas[6], ans[6];
int vsize;

vector < string > ans_strings, strings;
string s;

bool used[6];

void swap(int n, int m)
{
    int t = mas[n];
    mas[n] = mas[m];
    mas[m] = t;
}

void turn_l()
{
    swap(0, 1);
    swap(1, 2);
    swap(2, 3);
}

void turn_r()
{
    swap(2, 3);
    swap(1, 2);
    swap(0, 1);
}

void turn_d()
{
    swap(4, 3);
    swap(4, 5);
    swap(4, 1);
}

void turn_u()
{
    swap(4, 1);
    swap(4 ,5);
    swap(4, 3);
}

void check_gen()
{
    for (int i = 1; i <= vsize; i++)
    {
        if (mas[0] == v[i][0] && mas[1] == v[i][1] && mas[2] == v[i][2] && mas[3] == v[i][3] && mas[4] == v[i][4] && mas[5] == v[i][5]) return;
    }
    vsize++;
    for (int i = 0; i < 6; i++)
    {
        v[vsize][i] = mas[i];
//        cout << mas[i] << " ";
    }
 //   cout << endl;
}

void gen(int i)
{
    if (i == 8)
    {
        return;
    }
    check_gen();
    turn_l();
    gen(i + 1);
    turn_r();
    turn_r();
    gen(i + 1);
    turn_l();
    turn_u();
    gen(i + 1);
    turn_d();
    turn_d();
    gen(i + 1);
    turn_u();
}

bool compp(int a[6], int b[6])
{
    for (int i = 0; i < 6; i++)
    {
        if (a[i] < b[i]) return true;
        if (a[i] > b[i]) return false;
    }
}

void check()
{

    string s1 = "";
    for (int i = 0; i < 6; i++)
    {
        s1 = s1 + s[ans[i]];
    }
    strings.clear();
    for (int i = 1; i < 25; i++)
    {
        string st = "";
//        int k = i;
        for (int z = 0; z < 6; z++)
        {
            st = st + s1[v[i][z]];
        }
        strings.push_back(st);
    }
    sort(strings.begin(), strings.end());
    string st = strings[0];
    for (int i = 0; i < ans_strings.size(); i++)
    {
        if (ans_strings[i] == st) return;
    }
    ans_strings.push_back(st);
}

void per(int n)
{
    if (n == 6) check();
    for (int i = 0; i < 6; i++)
    {
        if (used[i]) continue;
        used[i] = true;
        ans[n] = i;
        per(n + 1);
        used[i] = false;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

//    per(0);

    for (int i =0; i < 6; i++)
    {
        mas[i] = i;
    }
    gen(0);

    getline(cin, s);

    per(0);

    cout << ans_strings.size();

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

char s[7];
int p[] = { 0, 1, 2, 3, 4, 5 }, dr[] = { 0, 5, 2, 4 };
set<string> st;
vector<string> v;

bool check() {
    string z = "";
    for (int i = 0; i < 4; ++i)
        z += s[p[i]];
    v.clear();
    for (int i = 0; i < 4; ++i) {
        char c = z[3];
        z.resize(3);
        z = c + z;
        string a = z + s[p[4]] + s[p[5]];
        for (int i = 0; i < 4; ++i) {
            string ss = "";
            ss += a[dr[(0 + i) % 4]];
            ss += a[1];
            ss += a[dr[(2 + i) % 4]];
            ss += a[3];
            ss += a[dr[(3 + i) % 4]];
            ss += a[dr[(1 + i) % 4]];
            if (st.find(ss) != st.end())
                return false;
            v.push_back(ss);
        }
    }
    for (size_t i = 0; i < v.size(); ++i)
        st.insert(v[i]);
    return true;
}

int main() {
//  freopen("a", "r", stdin);
    scanf("%s", s);
    int res = 0;
    do
        if (check())
            ++res;
    while (next_permutation(p, p + 6));
    printf("%d\n", res);
    return 0;
}

#include<cstdio>
#include<string.h>
#include<vector>
#include<map>
#include<string>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
string st, temp;
map<string, int> M;
int main()
{
#ifdef _DEBUG
    freopen("in.txt", "rt", stdin);
#endif
    cin >> temp;
    int i, j, k;
    sort(temp.begin(), temp.end());
    while(true)
    {
        string smin = temp;
        st = temp;
        for(i = 0; i < 4; ++i)
        {
            for(j = 0; j < 4; ++j)
            {
                for(k = 0; k < 4; ++k)
                {
                    if(st < smin)
                        smin = st;
                    char chk = st[1];
                    st[1] = st[2];
                    st[2] = st[4];
                    st[4] = st[5];
                    st[5] = chk;
                }
                if(st < smin)
                    smin = st;
                char chj = st[0];
                st[0] = st[2];
                st[2] = st[3];
                st[3] = st[5];
                st[5] = chj;
            }
            if(st < smin)
                smin = st;
            char chi = st[0];
            st[0] = st[1];
            st[1] = st[3];
            st[3] = st[4];
            st[4] = chi;
        }
        M[smin]++;
        if(!next_permutation(temp.begin(), temp.end()))
            break;
    }
    printf("%d", M.size());
    return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>

using namespace std;

set<string> uniq;
set<string> uniq2;

void rotate1(string &s)
{
	char t = s[0];
	for(int i = 0; i < 3; ++i)
		s[i] = s[i + 1];
	s[3] = t;
}

void rotate2(string &s)
{
	char t = s[3];
	s[3] = s[5];
	s[5] = s[1];
	s[1] = s[4];
	s[4] = t;
}

char ch[6] = {'R', 'O', 'Y', 'G', 'B', 'V'};
bool used[50000];

int id(string &s)
{
	int t = 0, base = 1, c = 0;
	for(int i = 0; i < s.size(); ++i)
	{
		c = -1;
		for(int j = 0; j < 6 && c == -1; ++j)
			if(s[i] == ch[j]) c = j;
		t += base*c;
		base *= 6;
	}

	return t;

}

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	string s;

	cin >> s;

    vector<char> a(4);
    vector<char> b(4);

    for(int i = 0; i < 50000; ++i)
    	used[i] = false;
    string s2 = s;

    uniq2.insert(s2);
    for(int i = 0; i < 790; ++i)
    {
    	next_permutation(s2.begin(), s2.end());
    	uniq2.insert(s2);
    }

    vector<string> u2(uniq2.begin(), uniq2.end());
    for(int i = 0; i < u2.size(); ++i)
    	used[id(u2[i])] = true;

    uniq.insert(s);
    s2 = s;

    int ans = 0;
    string s3, s4;
    for(int i = 0; i < u2.size(); ++i)
    {
    	if(!used[id(u2[i])])
    		continue;
    	s = u2[i];

    	for(int j = 0; j < 30000; ++j)
    	{
    		if(rand() & 1)
    			rotate1(s);
    		else
    			rotate2(s);
    		used[id(s)] = false;
    	}

    	ans++;
    }

    cout << ans;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int> > vvi;
typedef vector<pii> vii;
typedef vector<vector<pii> > vvii;
typedef long double ld;
typedef map<int, int> mapii;
typedef map<string, int> mapsi;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define INF  LLONG_MAX
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define pi  acos(-1)
#define mod(n,m) ((n % m + m) % m)
#define eps (1e-8)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'
#define output freopen("output.txt", "w", stdout)
#define mp(x, y, z) {x, {y, z}}

void hor(string &s)
{
	swap(s[0], s[1]);
	swap(s[1], s[2]);
	swap(s[2], s[3]);
}

void ver(string &s)
{
	swap(s[4], s[0]);
	swap(s[0], s[5]);
	swap(s[5], s[2]);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	string x;
	cin >> x;

	sort(all(x));

	set<string> st;

	do
	{
		string temp = x, mx = x;
		rep(i, 0, 4)
		{
			ver(temp);
			rep(j, 0, 4)
			{
				hor(temp);
				rep(k, 0, 4)
				{
					ver(temp);
					mx = max(mx, temp);
				}
			}
		}
		st.insert(mx);
	} while (next_permutation(all(x)));

	cout << sz(st) << endl;

	return 0;
}

#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

string clr;
set<string> vars;

string rotate(string s, int a, int b, int c, int d) {
	char ch;

	ch = s[a];
	s[a] = s[b];
	s[b] = s[c];
	s[c] = s[d];
	s[d] = ch;

	return s;
}

string rotate1(string s) {
	return rotate(s, 1, 2, 3, 4);
}

string rotate2(string s) {
	return rotate(s, 0, 2, 5, 4);
}

string rotate3(string s) {
	return rotate(s, 1, 0, 3, 5);
}

void all_rotation(string s, set<string> &used) {
	if (used.find(s) == used.end()) {
		used.insert(s);
		all_rotation(rotate1(s), used);
		all_rotation(rotate2(s), used);
		all_rotation(rotate3(s), used);
	}
}

string min_rotation(string s) {
	set<string> used;

	all_rotation(s, used);

	return *used.begin();
}

int main() {

#ifndef ONLINE_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
#endif

	cin >> clr;
	sort(clr.begin(), clr.end());
	do {
		vars.insert(min_rotation(clr));
	} while (next_permutation(clr.begin(), clr.end()));
	cout << vars.size();

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

set <string> perms;

string make_string(string x, int i, int j, int k, int l, int m, int n)
{
	return string(1, x[i - 1]) + string(1, x[j - 1]) + string(1, x[k - 1]) + string(1, x[l - 1]) + string(1, x[m - 1]) + string(1, x[n - 1]);
}

set <string> make_rotations(string x)
{
	set <string> ans;
	ans.insert(make_string(x, 1, 2, 3, 4, 5, 6));
	ans.insert(make_string(x, 6, 2, 5, 4, 1, 3));
	ans.insert(make_string(x, 3, 2, 1, 4, 6, 5));
	ans.insert(make_string(x, 5, 2, 6, 4, 3, 1));
	ans.insert(make_string(x, 1, 4, 3, 2, 5, 6));
	ans.insert(make_string(x, 6, 4, 5, 2, 1, 3));
	ans.insert(make_string(x, 3, 4, 1, 2, 6, 5));
	ans.insert(make_string(x, 5, 4, 6, 2, 3, 1));

	ans.insert(make_string(x, 4, 3, 2, 1, 5, 6));
	ans.insert(make_string(x, 6, 3, 5, 1, 4, 2));
	ans.insert(make_string(x, 2, 3, 4, 1, 6, 5));
	ans.insert(make_string(x, 5, 3, 6, 1, 2, 4));
	ans.insert(make_string(x, 4, 1, 2, 3, 5, 6));
	ans.insert(make_string(x, 6, 1, 5, 3, 4, 2));
	ans.insert(make_string(x, 2, 1, 4, 3, 6, 5));
	ans.insert(make_string(x, 5, 1, 6, 3, 2, 4));

	ans.insert(make_string(x, 1, 6, 3, 5, 2, 4));
	ans.insert(make_string(x, 4, 6, 2, 5, 1, 3));
	ans.insert(make_string(x, 3, 6, 1, 5, 4, 2));
	ans.insert(make_string(x, 2, 6, 4, 5, 3, 1));
	ans.insert(make_string(x, 1, 5, 3, 6, 2, 4));
	ans.insert(make_string(x, 4, 5, 2, 6, 1, 3));
	ans.insert(make_string(x, 3, 5, 1, 6, 4, 2));
	ans.insert(make_string(x, 2, 5, 4, 6, 3, 1));

	return ans;
}

int main()
{
	ios::sync_with_stdio(false);

	string x;
	cin>>x;

	int cnt[26] = {0};
	for (auto c: x)
		cnt[c - 'A']++;
	vector <int> cnts;
	for (int i = 0; i < 26; i++)
		if (cnt[i])
			cnts.push_back(cnt[i]);
	sort(cnts.begin(), cnts.end());
	reverse(cnts.begin(), cnts.end());
	char curr = 'A';
	string mys = "";
	for (int c: cnts)
	{
		while (c--)
			mys += curr;
		curr++;
	}
	x = mys;

	do
	{
		perms.insert(x);
	} while (next_permutation(x.begin(), x.end()));

	for (auto p: perms)
	{
		for (auto rot: make_rotations(p))
			if (p != rot && perms.find(rot) != perms.end())
				perms.erase(rot);
	}
	cout<<perms.size()<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pob pop_back
#define ite ::iterator
#define test int test_case; cin>>test_case; while(test_case--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define mp make_pair
#define endl "\n"
#define all(a) a.begin(),a.end()
const ll MOD = 1e9+7;

long double logg(ll k, ll r){
	return (log(r)/log(k));
}

int main(){
	std::ios::sync_with_stdio(false);	cin.tie(0);
	set<char> s;
	std::vector<char> v;
	char c;
	map<char, int> m;
	pair<set<char, int>::iterator, bool> p;
	rep(i, 0, 6){
		cin >> c;
		p = s.insert(c);
		m[c]++;
		if(p.second == true){
			v.pb(c);
		}
	}
	if(s.size()==1){
		cout << 1 << endl;
	}
	else if(s.size() == 2){
		if(m.begin()->second == 1 || m.begin()->second == 5){
			cout << 1 << endl;
		}
		else if(m.begin()->second == 2 || m.begin()->second == 4){
			cout << 2 << endl;
		}
		else{
			cout << 2 << endl;
		}
	}
	else if(s.size() == 3){
		if(m[v[0]]==4 || m[v[1]]==4 || m[v[2]]==4){
			cout << 2 << endl;
		}
		else if(m[v[0]]==2 && m[v[1]]==2 && m[v[2]]==2){
			cout << 6 << endl;
		}
		else cout << 3 << endl;
	}
	else if(s.size()==4){
		if(m[v[0]]==3 || m[v[1]]==3 || m[v[2]]==3 || m[v[3]]==3){
			cout << 5 << endl;
		}
		else cout << 8 << endl;
	}
	else if(s.size()==5){
		cout << 15 << endl;
	}
	else cout << 30 << endl;
	return 0;
}

#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define mp make_pair
#define pb push_back

using namespace std;

double eps = 1e-9;
const int INF = 1e9+7;
const int MAXN = int (3e5+7);

int n, ans;
char a[100], c[100];
set <ll> m;

ll hash1() {
	int p = 31;
	ll pw = 1;
	ll res = 0;
	for(int i = 0; i < 6; i ++) {
		res += (a[i] - 'A') * pw;
		pw *= p;
	}
	return res;
}

void go() {
	for(int i = 0; i < 6; i ++)
		a[i] = c[i];
	for(int i = 0; i < 4; i ++) {
		for(int j = 0; j < 4; j ++) {
			if(m.count(hash1()))
				return;
			swap(a[1], a[3]);
			swap(a[1], a[4]);
			swap(a[3], a[5]);
		}
		for(int j = 0; j < 3; j ++)
			swap(a[j], a[j + 1]);
	}
	a[0] = c[4], a[2] = c[5], a[4] = c[2], a[5] = c[0];
	for(int j = 0; j < 4; j ++) {
		if(m.count(hash1()))
			return;
		swap(a[1], a[3]);
		swap(a[1], a[4]);
		swap(a[3], a[5]);
	}
	a[0] = c[5], a[1] = c[3], a[2] = c[4], a[3] = c[1], a[4] = c[2], a[5] = c[0];
	for(int j = 0; j < 4; j ++) {
		if(m.count(hash1()))
			return;
		swap(a[1], a[3]);
		swap(a[1], a[4]);
		swap(a[3], a[5]);
	}
	for(int i = 0; i < 6; i ++)
		a[i] = c[i];
	m.insert(hash1());
	ans ++;
}

int main () {
   	//freopen("input.in", "r", stdin);
   	//freopen("output.txt", "w", stdout);

    scanf("%s", c);
    sort(c, c + 6);
    do {
    	go();
    } while(next_permutation(c, c + 6));
    printf("%d\n", ans);
    return 0;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

/* Prewritten code begins */
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0; i<(n); ++i)
#define SIZE(x)     (int)(x).size()
/* Prewritten code ends */

int perm[6][6] = {
	{0,1,2,3,4,5},
	{1,5,2,0,4,3},
	{2,5,3,0,1,4},
	{3,5,4,0,2,1},
	{4,5,1,0,3,2},
	{5,2,1,4,3,0}
};
set<string> se;
int main() {
	string s;
	cin >> s;
	sort(ALL(s));
	do {
		string t = string(6,'Z');
		REP(top,6) {
			REP(off,4) {
				string x;
				x += s[perm[top][0]];
				REP(i,4) x += s[perm[top][1+(i+off)%4]];
				x += s[perm[top][5]];
				if(x < t) t = x;
			}
		}
		se.insert(t);
	} while(next_permutation(ALL(s)));
	cout << SIZE(se) << endl;
	return 0;
}

#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

char buf[16];
vector<char> C;
vector<string> W;

inline string
canon(string s)
{
  string res("0000");

  for (int i = 0; i < 4; ++i)
    res[i] = s[i + 1];
  for (int i = 1; i < 4; ++i) {
    string str("0000");
    for (int j = 0; j < 4; ++j)
      str[j] = s[1 + (j + i) % 4];

    if (str < res)
      res = str;
  }

  string c1("0"), c2("0");

  c1[0] = s[0];
  c2[0] = s[5];

  res = c1 + res + c2;

  return (res);
}

inline void
add()
{

  string res("000000");
  for (int i = 0; i < 6; ++i)
    res[i] = C[i];
  res = canon(res);

  vector<string> r;

  r.push_back(res);

  if (true) {
    string res2(res);
    res2[1] = res[5];
    res2[5] = res[3];
    res2[3] = res[0];
    res2[0] = res[1];

    r.push_back(canon(res2));
  }

  if (true) {
    string res2(res);

    res2[0] = res[2];
    res2[4] = res[0];
    res2[5] = res[4];
    res2[2] = res[5];

    r.push_back(canon(res2));
  }

  if (true) {
    string res2(res);

    res2[1] = res[0];
    res2[5] = res[1];
    res2[3] = res[5];
    res2[0] = res[3];

    r.push_back(canon(res2));
  }

  if (true) {
    string res2(res);

    res2[4] = res[5];
    res2[5] = res[2];
    res2[2] = res[0];
    res2[0] = res[4];

    r.push_back(canon(res2));
  }

  if (true) {
    string res2(res);

    res2[0] = res[5];
    res2[5] = res[0];
    res2[2] = res[4];
    res2[4] = res[2];

    r.push_back(canon(res2));
  }

  sort(r.begin(), r.end());

  W.push_back(r[0]);
}

int
main()
{
  scanf("%s", buf);

  for (int i = 0; i < 6; ++i)
    C.push_back(buf[i]);

  sort(C.begin(), C.end());

  int na = 1;

  for (int i = 1; i < 6; ++i)
    if (C[i] == C[0])
      ++na;

  do {
    add();
  } while (next_permutation(C.begin() + 1, C.end()));

  sort(W.begin(), W.end());

  vector<string>::iterator ne = unique(W.begin(), W.end());

  printf("%d\n", (int)(ne - W.begin()));

  return (0);
}

/*
 ID: ahaigh11
 PROG: codeforces contest #78
 URL:
 LANG: C++

 */
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <utility>
#include <cassert>
#include <queue>
#include <ctime>
#include <map>
#include <set>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define CL(x) memset(x, 0, sizeof(x))
typedef pair<double, double> is;

//top, left, front, right, back, bottom
string inc[6] = {"011112","103231","110121","121011",",112101","211110"};
string near[6] = {"1234","0254","0153","4520","3510","4321"};
int opp[6] = {5,3,4,1,2,0};

char t[7], s[7]; string t_p;
bool seen[6];
set<string> se;

void dfs(int x, int v) {
	seen[x] = true; t[v] = s[x];
	if (v == 5) {
		//cout << t << endl;
		t_p = min((string)t, t_p);
	} else {
		for (int i = 0; i < 6; i++) {
			if (inc[x][i] == '1' && !seen[i]) {
				dfs(i, v+1);
			}
		}
	}
	seen[x] = false;
}

int X[4] = {1,2,3,4}, Y[4] = {0,1,5,3}, Z[4] = {0,2,5,4};
void cycle(int* r) {
	int x = t[ r[0] ];
	t[ r[0] ] = t[ r[1] ];
	t[ r[1] ] = t[ r[2] ];
	t[ r[2] ] = t[ r[3] ];
	t[ r[3] ] = x;
}

int main() {
	t[6] = '\0';
	while (cin >> s) {
		se.clear();
		sort(s, s+6);
		do {
			//this is a colouring
			REP(i, 6) t[i] = s[i];
			t_p = "ZZZZZZ";

			REP(i, 4) {
				REP(j, 4) {
					REP(k, 4) {
						t_p = min((string)t, t_p);
						cycle(X);
					}
					cycle(Y);
				}
				cycle(Z);
			}

			//cout << s << " " << t_p << endl;
			se.insert(t_p);

		} while (next_permutation(s, s+6));

		//for (set<string>::iterator q = se.begin(); q != se.end(); q++) cout << *q << endl;

		cout << se.size() << endl;
	}
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

int funk(int *a,int len)
{
    int i,j,sum=0;
    for(i=len-1,j=0;i>=0;i--,j++)
    {
        sum+=a[i]*pow(10,j);
    }
    return sum;
}
int main() {
    int a[6], i;
    char b[10];

    while(~scanf("%s", b)) {
        memset(a, 0, sizeof(a));
        for (i = 0; i < 6; i++) {
            if (b[i] == 'R')
                a[0]++;
            else if (b[i] == 'O')
                a[1]++;
            else if (b[i] == 'Y')
                a[2]++;
            else if (b[i] == 'G')
                a[3]++;
            else if (b[i] == 'B')
                a[4]++;
            else
                a[5]++;
        }
        sort(a, a + 6, greater<int>());
        int kkk = funk(a, 6);

            if (kkk == 600000)printf("1\n");
            if (kkk == 510000)printf("1\n");
            if (kkk == 420000)printf("2\n");
            if (kkk == 330000)printf("2\n");
            if (kkk == 411000)printf("2\n");
            if (kkk == 321000)printf("3\n");
            if (kkk == 311100)printf("5\n");
            if (kkk == 222000)printf("6\n");
            if (kkk == 221100)printf("8\n");
            if (kkk == 211110)printf("15\n");
            if (kkk == 111111)printf("30\n");
        }

    return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define M                 1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define fbo               find_by_order
#define ook               order_of_key

template<typename T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mii m;
int a[10],b[10],ans=1;
void solve(){
	m['R']=0;
	m['O']=1;
	m['Y']=2;
	m['G']=3;
	m['B']=4;
	m['V']=5;
	for(int i=0;i<6;i++){
    	char c;
    	cin>>c;
    	a[m[c]]++;
    }
    for(int i=0;i<6;i++){
    	b[a[i]]++;
    }
    if(b[6]||b[5]){
    	cout<<1;
    	return;
    }
    if(b[4]){
    	cout<<2;
    	return;
    }
    if(b[3]==2)cout<<2;
    else if(b[3]){
    	if(b[2]) cout<<3;
    	else cout<<5;
    }
    else if(b[2]==0){
    	cout<<30;
    }
    else if(b[2]==1){
    	cout<<15;
    }
    else if(b[2]==3){
    	cout<<6;
    }
    else{
    	cout<<8;
    }
}
signed main(){
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

#include <bits/stdc++.h>

void rotate_x(std::string& a) {
    char c = a[1]; a[1] = a[2]; a[2] = a[3]; a[3] = a[4]; a[4] = c;
}

void rotate_y(std::string& a) {
    char c = a[0]; a[0] = a[1]; a[1] = a[5]; a[5] = a[3]; a[3] = c;
}

void rotate_z(std::string& a) {
    char c = a[0]; a[0] = a[2]; a[2] = a[5]; a[5] = a[4]; a[4] = c;
}

bool is_equal(std::string& a, std::string& b) {
    std::string c = b;
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 4; ++k) {
                if (a == c) {
                    return true;
                }
                rotate_z(c);
            }
            rotate_y(c);
        }
        rotate_x(c);
    }
    return false;
}

int main(void) {
    std::string str;
    std::cin >> str;
    std::sort(str.begin(), str.end());
    std::vector<std::string> unique;
    do {
        bool fl = true;
        for (int i = 0; i < unique.size(); ++i) {
            if (is_equal(unique[i], str)) {
                fl = false;
                break;
            }
        }
        if (fl) {
            unique.push_back(str);
        }
    } while (std::next_permutation(str.begin(), str.end()));
    std::cout << unique.size() << std::endl;
    return 0;
}

#include <iostream>

#include <stdlib.h>
#include <string.h>

using namespace std;

void getmax(int *mass, int *firstmax, int *secondmax, int *thirdmax)
{
	*firstmax = 0;
	*secondmax = 0;
	*thirdmax = 0;
	for(int i = 0; i < 6; i++)
	{
		if(mass[i] >= *firstmax)
		{
			*thirdmax = *secondmax;
			*secondmax = *firstmax;
			*firstmax = mass[i];
		}
		else if(mass[i] >= *secondmax)
		{
			*thirdmax = *secondmax;
			*secondmax = mass[i];;
		}
		else if(mass[i] >= *thirdmax)
			*thirdmax = mass[i];
	}
}

int main(int argc, char *argv[])
{
		char str[7];
		int colors[6] = {0}; //1 - R; 2 - O; 3 - Y; 4 - G; 5 - B; 6 - V
		cin >> str;
		for(int i = 0; i < 6; i++)
		{
			if(str[i] == 'R')
				colors[0]++;
			else if(str[i] == 'O')
				colors[1]++;
			else if(str[i] == 'Y')
				colors[2]++;
			else if(str[i] == 'G')
				colors[3]++;
			else if(str[i] == 'B')
				colors[4]++;
			else
				colors[5]++;
		}
		int max1, max2, max3;
		getmax(colors, &max1, &max2, &max3);
		if(max1 >= 5)
			cout << "1" << endl;
		else if(max1 == 4)
			cout << "2" << endl;
		else if(max1 == 3)
		{
			if(max2 == 3)
				cout << "2" << endl;
			else if(max2 == 2)
				cout << "3" << endl;
			else
				cout << "5" << endl;
		}
		else if(max1 == 2)
		{
			if(max2 == 1)
				cout << "15" << endl;
			else
			{
				if(max3 == 1)
					cout << "8" << endl;
				else
					cout << "6" << endl;
			}
		}
		else
			cout << "30" << endl;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string.h>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define F(a,b) for(int i = a;i <= b;i ++)
#define int_max 99999999999LL
#define eps 1.0e-6
#define max 100
string aa;
int visited[max];
char str[7] = {'R','O','Y','G','B','V'};
int a[max];
int main() {
    cin>>aa;
    int  N = 0;
    for(int j = 0;j <= 5;j ++){
        visited[j] = 0;
        for(int l = 0;l <= aa.length()-1;l ++){
            if(str[j] == aa[l]){
                visited[j] ++;
            }
        }
    }
    int count = 1;
    for(int j = 0;j <= 5;j ++){
        if(visited[j]!=0)
			a[count ++] = visited[j];
    }
    count --;
    if(count == 1)
		cout<<1<<endl;
    if(count == 6)
		cout<<30<<endl;
    if(count == 5)
		cout<<15<<endl;
	if(count == 4){
        int flag = 0;
        for(int j = 1;j <= count; j++){
            if(a[j] == 3) {
                flag = 1;
                break;
            }
        }
        if(!flag)
			cout<<8<<endl;
        else
			cout<<5<<endl;
    }
   if(count == 3){
        int flag = 1;
        for(int j = 1;j <= count;j ++){
            if(a[j] == 4){
                flag = 0;
                break;
            }
            if(a[j] == 3){
                flag = 2;
                break;
            }
        }
        if(flag == 1)
			cout<<6<<endl;
        else
			if(flag == 2)
				cout<<3<<endl;
        else
			if(flag == 0)
				cout<<2<<endl;
        }
    if(count == 2){
        int ff = 0;
        for(int j = 1;j <= count;j ++){
            if(a[j] == 3){
                cout<<2<<endl;
                break;
            }
            if(a[j] == 1){
                cout<<1<<endl;
                break;
            }
            if(a[j] == 2){
                cout<<2<<endl;
                break;
            }
        }
    }
    return 0;
}

#define _CRT_SECURE_NO_DEPRECATE
#include <ctime>
#include <float.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
using namespace std;
#define pb push_back
#define inf 1000000000
#define L(s) (int)(s).size()
#define rp(i,n) for(int (i)=0;(i)<(n);++(i))
#define C(a) memset((a),0,sizeof(a))
#define ll long long
#define all(c) (c).begin(), (c).end()
#define VI vector<int>
#define mp make_pair
#define pii pair<int,int>
//#define pdd pair<double,double>
//#define x first
//#define y second
set<string> s;
queue<string> q;
string left(string t)
{
	string a="AAAAAA";
	a[0]=t[1];
	a[1]=t[2];
	a[2]=t[3];
	a[3]=t[0];
	a[4]=t[4];
	a[5]=t[5];
	return a;
}
string up(string t)
{
	string a="AAAAAA";
	a[1]=t[4];
	a[4]=t[3];
	a[3]=t[5];
	a[5]=t[1];
	a[0]=t[0];
	a[2]=t[2];
	return a;
}
string in;
int main()
{
	cin>>in;
	sort(all(in));
	int ans=0;
	do
	{
		if (s.find(in)!=s.end())
			continue;
		ans++;
		s.insert(in);
		q.push(in);
		while(!q.empty())
		{
			string tin=q.front();
			q.pop();
			if (s.find(left(tin))==s.end())
			{
				s.insert(left(tin));
				q.push(left(tin));
			}
			if (s.find(up(tin))==s.end())
			{
				s.insert(up(tin));
				q.push(up(tin));
			}
		}
	}while(next_permutation(all(in)));
	cout<<ans<<endl;
}

#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <cassert>
#include <algorithm>

using namespace std;

typedef long double ldb;
typedef long long int64;

double const pi = 3.1415926535897932384626433832795;
int const inf = (int) 1e9;
int64 const inf64 = (int64) 2e18;

#define y1 qqqqqqq
#define forn(i, n) for (int i = 0; i < (int) n; i++)
#define seta(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define pii pair < int, int >
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define fs first
#define sc second
#define sqr(x) ((int64) x) * (x)

const string name = "a";

int p[10];
set <string> S;
int n;
string s;

void rotate(string &now, int x)
{
	string tmp = now;
	if (x == 0)
	{
		tmp[0] = now[1];
		tmp[1] = now[2];
		tmp[2] = now[3];
		tmp[3] = now[0];
	}
	if (x == 1)
	{
		tmp[1] = now[4];
		tmp[5] = now[1];
		tmp[3] = now[5];
		tmp[4] = now[3];
	}
	if (x == 2)
	{
		tmp[0] = now[5];
		tmp[4] = now[0];
		tmp[2] = now[4];
		tmp[5] = now[2];
	}
	now = tmp;
}

void solve()
{
	string now = "";
	forn(i, n)
		now += s[p[i]];
	string ans = now;
	forn(i, 4)
	{
		rotate(now, 0);
		forn(j, 4)
		{
			rotate(now, 1);
			forn(f, 4)
			{
				ans = min(ans, now);
				rotate(now, 2);
			}
		}
	}
	S.insert(ans);
}

int main()
{
	//freopen((name + ".in").data(), "r", stdin);
	//freopen((name + ".out").data(), "w", stdout);

	n = 6;
	cin >> s;
	forn(i, n)
		p[i] = i;
	solve();
	while (next_permutation(p, p + n))
		solve();
	cout << S.size() << endl;

	return 0;
}

#include <bits/stdc++.h>
typedef long long li;
typedef unsigned long long uli;
#define inf  (int)(1e9)
#define inf2 (li)(LLONG_MAX-1)
#define pb push_back
#define F first
#define S second
#define R return
#define C continue
#define B break
#define MP make_pair
#define MOD (li)(1e9+7)
#define M_PI acos(-1)
using namespace std;
char s[10];
int ar[10];
int main(){

    scanf("%s",&s);
    for(int i=0;i<6;i++)
    {
            if(s[i]=='R')ar[0]++;
            if(s[i]=='O')ar[1]++;
            if(s[i]=='Y')ar[2]++;
            if(s[i]=='G')ar[3]++;
            if(s[i]=='B')ar[4]++;
            if(s[i]=='V')ar[5]++;
    }
    sort(ar,ar+6);
    if(ar[5]==6 ||ar[5]==5) cout << 1 << endl;
    else if(ar[5]==4) cout << 2 << endl;
    else if(ar[5]==3 && ar[4]==1) cout << 5 << endl;
    else if(ar[5]==3 && ar[4]==2) cout << 3 << endl;
    else if(ar[5]==3 && ar[4]==3) cout << 2 << endl;
    else if(ar[5]==2 && ar[4]==1) cout << 15 << endl;
    else if(ar[5]==2 && ar[4]==2 && ar[3]==2) cout << 6 << endl;
    else if(ar[5]==2 && ar[4]==2) cout << 8 << endl;
    else if(ar[5]==1) cout << 30 << endl;

    R 0;
}

/////////////////////////////////////////////////
// *** Solution By Bektemir Doolotbek uulu *** //
/////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define buli(x) __builtin_popcountll(x)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double d;

const int mod=1000000007;
const int N=1001;
const int M=100005;
const ld pi=acos(-1);

string s;
set<string> st;
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> s;
	sort( s.begin(), s.end() );
	do {
		vector< string > v;
		for( int i = 0; i < 3; i++ ) {
			v.push_back( s.substr( 2 * i, 2 ) );
			sort( v.back().begin(), v.back().end() );
		}
		sort( v.begin(), v.end() );
		string tmp = v[0] + v[1] + v[2];
		st.insert( tmp );
		if( v[0] != v[1] && v[1] != v[2] && v[2] != v[0] && tmp[0] != tmp[1] && tmp[2] != tmp[3] ) {
			swap( tmp[4], tmp[5] );
			st.insert( tmp );
		}
	} while( next_permutation( s.begin(), s.end() ) );
	cout << st.size() << endl;
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <numeric>
#include <limits>
#include <iterator>
using namespace std;

const int INF=(1<<30)-1;
const int DIRX[]={-1, 0, 0, 1,-1,-1, 1, 1}, DIRY[]={ 0,-1, 1, 0,-1, 1,-1, 1};
const double ERR=1e-11, PI=(2*acos(0.0));

#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)<(b)?(b):(a))
template<class T> inline T MIN(T a,T b) {return ((a<b)?(a):(b));}
template<class T> inline T MAX(T a,T b) {return ((b<a)?(a):(b));}
template<class T> inline T ABS(T a) {return ((a<(T)0)?(-a):(a));}
template<class T> inline void checkMIN(T& a,T b) {if(b<a) a=b;}
template<class T> inline void checkMAX(T& a,T b) {if(a<b) a=b;}
template<class T> T SQR(T x) {return (x*x);}
template<class T> T GCD(T a,T b) {if(!b) return a; else return GCD(b,a%b);}
template<class T> T fastPow(T Base,T Power)
{T Result=(T)1; while(Power>0) {if(Power&(T)1)Result*=Base; Power>>=1; Base*=Base;} return Result;}
template<class T> T modPow(T Base,T Power,T Mod)
{T Result=(T)1; while(Power>0) {if(Power&(T)1)Result=(Result*Base)%Mod; Power>>=1;Base=(Base*Base)%Mod;}return (Result%Mod);}
inline int CompareDouble(double x,double y,double err=ERR) { double d=x-y; if(d>err) return 1; if(d<-err) return -1; return 0;}

#define DUMP(x)     cout << #x << " = " << x << endl;
#define rep(x,n)    for(x=0;x<(int)(n);x++)
#define fori(x,a,b) for(x=(a);x<=(b);x++)
#define ford(x,a,b) for(x=(a);x>=(b);x--)
#define Mem(X,byte) memset((X),(byte),sizeof(X))
#define all(X)      (X).begin(),(X).end()
#define Size(X)     ((int)(X).size())
#define Each(X,itr) for( __typeof((X).begin()) itr=(X).begin(); itr!=(X).end(); itr++)
#define Contains(X,item)    ((X).find(item) != (X).end())
#define Contains_n(X,item)  (find((X).begin(),(X).end(),(item)) != (X).end())
#define PB  push_back
#define MP  make_pair
#define fs  first
#define sc  second

typedef unsigned long long ULL;
typedef long long      LL;
typedef stringstream   SS;
typedef vector<string> VS;
typedef vector<double> VD;
typedef vector<LL>     VL;
typedef vector<int>    VI;
typedef pair<int,int>  Pii;

struct Die
{
#define T s[0]
#define N s[1]
#define E s[2]
#define W s[3]
#define S s[4]
#define B s[5]
#define CYC( a, b ) t = T; T = a; a = B; B = b; b = t; break;

    string s;

    Die( string ss ) : s( ss ) {}

    void roll( char d )
    {
        char t;
        switch( d )
        {
            case 'n': CYC( S, N );
            case 'e': CYC( W, E );
            case 'w': CYC( E, W );
            case 's': CYC( N, S );
        }
    }

    char get( char d )
    {
        switch( d )
        {
            case 't': return T;
            case 'n': return N;
            case 'e': return E;
            case 'w': return W;
            case 's': return S;
            case 'b': return B;
        }
        return 0;
    }

#undef T
#undef N
#undef E
#undef W
#undef S
#undef B
#undef CYC
};

set<string> m;

bool myFunc(Die d) {
    int i;
    /*rep(i,4) {
        if(Contains(m,d.s)) return false;
        d.roll('n');
    }
    rep(i,4) {
        if(Contains(m,d.s)) return false;
        d.roll('e');
    }*/
    rep(i,4) {
        if(Contains(m,d.s)) return false;
        d.roll('w');
        d.roll('s');
        d.roll('e');
    }
    return true;
}

int main()
{
    int _kase = 1;
    #ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    _kase = 3;
    #endif

    int i,j,k,n;
    string str;
    bool b;

    while(_kase--)
    {
        m.clear();
        cin>>str;
        sort(all(str));

        do {
            bool b=true;

            if(b) {
                Die d(str);
                b=myFunc(d);
            }

            if(b) {
                Die d(str);
                d.roll('n');
                b=myFunc(d);
            }

            if(b) {
                Die d(str);
                d.roll('e');
                b=myFunc(d);
            }

            if(b) {
                Die d(str);
                d.roll('w');
                b=myFunc(d);
            }

            if(b) {
                Die d(str);
                d.roll('s');
                b=myFunc(d);
            }

            if(b) {
                Die d(str);
                d.roll('n');
                d.roll('n');
                b=myFunc(d);
            }

            if(b) m.insert(str);
        } while(next_permutation(all(str)));

        cout<<Size(m)<<endl;
    }

    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

//OBROTY

string Z(string kol)
{
    string wyn = "abcdef";
    wyn[0] = kol[4];
    wyn[1] = kol[5];
    wyn[2] = kol[2];
    wyn[3] = kol[3];
    wyn[4] = kol[1];
    wyn[5] = kol[0];
    return wyn;
}

string Y(string kol)
{
    string wyn = "abcdef";
    wyn[0] = kol[2];
    wyn[1] = kol[3];
    wyn[2] = kol[1];
    wyn[3] = kol[0];
    wyn[4] = kol[4];
    wyn[5] = kol[5];
    return wyn;
}

string X(string kol)
{
    string wyn = "abcdef";
    wyn[0] = kol[0];
    wyn[1] = kol[1];
    wyn[2] = kol[5];
    wyn[3] = kol[4];
    wyn[4] = kol[2];
    wyn[5] = kol[3];
    return wyn;
}

int main()
{
    ios_base::sync_with_stdio(0);
    string nap;
    cin >> nap;
    string T, t;
    vector<char> kol(6);
    for (int i = 0; i < 6; ++i) kol[i] = nap[i];
    sort(kol.begin(), kol.end());
    vector<string> spo;
    do
    {
        T = "";
        t = "";
        for (int i = 0; i < 6; ++i) T += kol[i];
        t = T;
        vector<string> obr;
        for (int i = 0; i < 4; ++i)
        {
           obr.push_back(t);
           t = X(t);
        }
        t = Y(t);
        for (int i = 0; i < 4; ++i)
        {
           obr.push_back(t);
           t = Z(t);
        }
        t = Y(t);
        for (int i = 0; i < 4; ++i)
        {
           obr.push_back(t);
           t = X(t);
        }
        t = Y(t);
        for (int i = 0; i < 4; ++i)
        {
           obr.push_back(t);
           t = Z(t);
        }
        t = X(t);
        for (int i = 0; i < 4; ++i)
        {
           obr.push_back(t);
           t = Y(t);
        }
        t = X(t);
        t = X(t);
        for (int i = 0; i < 4; ++i)
        {
           obr.push_back(t);
           t = Y(t);
        }
        bool jest = false;
        for (int i = 0; i < 24; ++i) for (int j = 0; j < spo.size(); ++j) if (obr[i] == spo[j]) jest = true;
        if (!jest) spo.push_back(T);
    } while (next_permutation(kol.begin(), kol.end()));
    cout << spo.size();
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <iostream>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;

#define EPS 1E-8

#define rep(i,n) for( i=0; i<(n); i++ )
#define VI vector<int>
#define PB push_back
#define LL long long

char str[100];
int u[10];
int c[10];
int list[1000][6];
int n,sum;
int tb[24][6]={
    {0,1,2,4,3,5},
    {5,3,4,2,1,0},
    {1,5,2,0,3,4},
    {4,3,0,2,5,1},
    {2,0,1,5,4,3},
    {3,4,5,1,0,2},
};

int check() {
    int i,j,k;
    for( i=0; i<n; i++ ) {
	for( j=0; j<24; j++ ) {
	    for( k=0; k<6; k++ ) {
		if(list[i][tb[j][k]]!=c[tb[0][k]]) break;
	    }
	    if(k==6) return 0;
	}
    }
    for( k=0; k<6; k++ ) {
	list[n][k] = c[k];
    }
    n++;
    return 1;
}

void dfs(int d) {
    int i;
    if(d==6) {
	sum+=check();
    }else {
	for( i=0; i<6; i++ ) {
	    if(!u[i]) {
		u[i] = 1;
		c[d] = str[i];
		dfs(d+1);
		u[i] = 0;
	    }
	}
    }
}

int main() {
    int i,j,k,l,z;
    for( i=1; i<4; i++ ) {
	for( j=0; j<6; j++ ) {
	    for( k=0; k<4; k++ ) {
		tb[i*6+j][k+1] = tb[i*6+j-6][(k+1)%4+1];
	    }
	    tb[i*6+j][0] = tb[i*6+j-6][0];
	    tb[i*6+j][5] = tb[i*6+j-6][5];
	}
    }
    scanf("%s",str);
    n = sum = 0;
    dfs(0);
    printf("%d\n",sum);
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
string s;
vector <int> a(6,0);
bool gr(int p,int q){return p>q;}
int main()
{
    cin >> s;
    for (int i=0;i<6;i++)
    {
        if (s[i]=='R') a[0]++;
        if (s[i]=='O') a[1]++;
        if (s[i]=='Y') a[2]++;
        if (s[i]=='G') a[3]++;
        if (s[i]=='B') a[4]++;
        if (s[i]=='V') a[5]++;
    }
    sort(a.begin(),a.end(),gr);
    if (a[0]==6) cout << 1;
    else if (a[0]==5) cout << 1;
    else if (a[0]==4)
    {
        if (a[1]==2) cout << 2;
        else cout << 2;
    }
    else if (a[0]==3)
    {
        if (a[1]==3) cout << 2;
        else if (a[1]==2) cout << 3;
        else cout << 5;
    }
    else if (a[0]==2)
    {
        if (a[1]==2)
        {
            if (a[2]==1) cout << 8;
            else cout << 6;
        }
        else cout << 15;
    }
    else cout << 30;
    return 0;
}

#include<stdio.h>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define carpe_diem ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define endl '\n'
#define S second
#define F first
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
const int M = 1e5+7;

void rot1(string &s)
{
    swap(s[0],s[1]);
    swap(s[1],s[2]);
    swap(s[2],s[3]);
}

void rot2(string &s)
{
    swap(s[0],s[4]);
    swap(s[4],s[2]);
    swap(s[2],s[5]);
}

string work(string s)
{
    string ret=s;
    for(int i=0; i<4; i++)
    {
        for(int j=0; j<4; j++)
        {
            for(int k=0; k<4; k++)
            {
                rot1(s);
                ret=min(ret,s);
            }
            rot2(s);
        }
        rot1(s);
    }
    return ret;
}

int main()
{
    carpe_diem
    string s; cin>>s;
    unordered_set<string> st;
    sort(s.begin(), s.end());
    do
    {
        st.insert(work(s));
        // cout<<work(s)<<endl;
    }
    while(next_permutation(s.begin(),s.end()));
    cout<<st.size()<<endl;
}

#include <cassert>
#include <complex>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <sstream>
#include <utility>

#include <algorithm>
#include <bitset>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <memory.h>
//#include "bigint.h"

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define init(st) memset(st, 0, sizeof(st))
#define ll long long

// String operations
template<class T>
void splitstr(const string &s, vector<T> &out) {
    istringstream in(s);
    out.clear();
    copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}

string read_line() {
    string ret_val;
    getline(std::cin, ret_val);
    return ret_val;
}

template<class T>
void init_array(T *arr, int size, T value) {
    for (int i = 0; i < size; i++)
        arr[i] = value;
}

// Arithmetic operations
template<class T>
inline T gcd(T a, T b) {
    return (!a) ? b : gcd(b % a, a);
}

template<class T>
inline T mod(T a, T p) {
    a %= p;
    return (a < 0) ? a + p : a;
}

template<class T>
inline int num_bits(T n) {
    return (!n) ? 0 : 1 + num_bits(n & (n - 1));
}

template<class T>
inline T inverse(T a, T m) {
    a = mod<T>(a,m);
    return (a==1) ? 1 : mod((1-m*inverse(m%a,a))/a,m);
}

template<class T>
inline bool is_prime(T a) {
    T lim = (T)sqrt((double)a);
    for (T i = 2; i <= T(lim+1E-9); i++)
        if (a % i == 0)
           return false;
    return true;
}

template<class T>
inline T power(T a, T p, T mod) {
    if (!p) return 1;
    T temp = power(a, p>>1, mod);
    temp = (temp * temp) % mod;
    if (p&1) temp = (temp * a) % mod;
    return temp;
}

void get_primes(int start, int end, vector<int> &vi) {
    int *p = new int[end + 1];
    init_array<int>(p, end+1, 0);
    for (int i = 2; i <= end; i++) {
        if (p[i]) continue;
        if (i >= start) vi.push_back(i);
        for (int j = 2*i; j <= end; j += i) p[j] = 1;
    }
    delete [] p;
}

// Graph operations
bool dfs(int current, int final, int total, int* visited, int **edges, bool flow) {
    if (current == final) return true;
    if (visited[current]) return false;
    visited[current] = true;
    for (int i = 0; i < total; i++)
        if (edges[current][i] && dfs(i, final, total, visited, edges, flow)) {
            if (flow) {
                edges[current][i]--;
                edges[i][current]++;
            }
            return true;
        }
    return false;
}

int flow(int in, int out, int total, int **edges) {
    int result = 0;
    int *visited = new int[total];
    while (init_array<int>(visited, total, 0), dfs(in, out, total, visited, edges, true))
        result++;
    delete [] visited;
    return result;
}

// Disjoint datasets
void create_set(int x, int *P, int *rank) {
    P[x] = x;
    rank[x] = 0;
}

int find_set(int x, int *P) {
    if (x != P[x]) P[x] = find_set(P[x], P);
    return P[x];
}

bool merge_sets(int x, int y, int *P, int *rank) {
    int Px = find_set(x, P);
    int Py = find_set(y, P);
    if(Px == Py) return false;
    if (rank[Px] > rank[Py]) P[Py] = Px;
    else P[Px] = Py;
    if (rank[Px] == rank[Py]) rank[Py]++;
    return true;
}

// Binary tree operations
template <typename T>
int read_cum_freq(int index, T *tree) {
    int sum = 0;
    while (index) {
        sum += tree[index];
        index -= (index & -index);
    }
    return sum;
}

template <typename T>
void upd_freq(int index, int mxIndex, int value, T *tree) {
    while (index <= mxIndex) {
        tree[index] += value;
        index += (index & -index);
    }
}

template <typename T>
int read_freq(int index, T *tree) {
    return read_cum_freq(index, tree) - read_cum_freq(index-1, tree);
}

// String algos.
void build_failure_function(const string &str, int *temp_arr) {
    temp_arr[0] = temp_arr[1] = 0;
    for (int i = 2; i <= sz(str); i++) {
        temp_arr[i] = -1;
        for (int ind = temp_arr[i-1]; temp_arr[i] == -1; ind = temp_arr[ind]) {
            if (str[ind] == str[i-1]) {
                temp_arr[i] = ind + 1;
            } else if (ind == 0) {
                temp_arr[i] = 0;
            }
        }
    }
}

void KMP(const string &text, const string &pattern, int *res) {
    int *temp_arr = new int[sz(pattern) + 1];
    build_failure_function(pattern, temp_arr);
    int i = 0;
    int ind = 0;
    while (i < sz(text)) {
        if (text[i] == pattern[ind]) {
            res[i] = ++ind;
            if (res[i] == sz(pattern)) {
                ind = temp_arr[ind];
            }
            i++;
        } else if (ind == 0) {
            res[i++] = 0;
        } else {
            ind = temp_arr[ind];
        }
    }
    delete [] temp_arr;
}

template<typename T, int N>
struct matrix {
    T m[N][N];
    T md;

    matrix(T md, bool unary = false) {
        this->md = md;
        init(m);
        if (unary) {
            for (int i = 0; i < N; i++)
                m[i][i] = 1;
        }
    }

    matrix operator*(const matrix &that) const {
        matrix ret_val(md, false);
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                for (int k = 0; k < N; k++) {
                    ret_val.m[i][j] += this->m[i][k] * that.m[k][j];
                    ret_val.m[i][j] %= md;
                }
        return ret_val;
    }

    vector<T> operator*(const vector<T> &vec) const {
        vector<T> ret_val(vec.size(), 0);
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++) {
                ret_val[i] += m[i][j] * vec[j];
                ret_val[i] %= md;
            }
        return ret_val;
    }

    matrix power(int pw) const {
        if (!pw) return matrix(md, true);
        if (pw == 1) return *this;
        matrix ret_val = power(pw>>1);
        ret_val = ret_val * ret_val;
        if (pw & 1) ret_val = ret_val * (*this);
        return ret_val;
    }
};

// Setup
void setup(int value, string name) {
    string name_in = name + ".in";
    string name_out = name + ".out";
    freopen(name_in.c_str(), "r", stdin);
    if (value) freopen(name_out.c_str(), "w", stdout);
}

int main() {
#ifdef LOCAL_HOST
    setup(0, "temp");
#endif
    string str; std::cin >> str;
    set<string> st;
    sort(str.begin(), str.end());
    int res = 0;
    do {
        vector<string> sv;
        bool flag = false;
        for (int i = 0; i < 6; i+=2) {
            sv.push_back(str.substr(i, 2));
            sort(sv.back().begin(), sv.back().end());
            if (sv.back()[0] == sv.back()[1]) flag = true;
        }
        sort(sv.begin(), sv.end());
        string elem = sv[0] + sv[1] + sv[2];
        if (st.count(elem)) continue;
        st.insert(elem);
        if (flag || (sv[0] == sv[1]) || (sv[1] == sv[2])) ++res;
        else ++++res;
    } while (next_permutation(str.begin(), str.end()));
    std::cout << res << std::endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#include<bitset>
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef  long double lld;
const int mx = 1e5 + 10;
map<string, int>m;
map<string, bool>xy, yz, zx;
void rotate_xy(string &);
void rotate_yx(string &);
void rotate_yz(string &);
void rotate_zy(string &);
void rotate_zx(string &);
void rotate_xz(string &);

void rotate_xy(string &s){
    if(xy[s])return;
    xy[s] = true;
    m[s] = true;
        char c = s[4];
        s[4] = s[2];
        s[2] = s[1];
        s[1] = s[0];
        s[0] = c;
        rotate_xy(s);
        rotate_yx(s);
        rotate_yz(s);
        rotate_zy(s);
        rotate_zx(s);
        rotate_xz(s);
}
void rotate_yz(string &s){
    if(yz[s])return;
     yz[s] = true;
     m[s] = true;
       char c = s[5];
        s[5] = s[2];
        s[2] = s[3];
        s[3] = s[0];
        s[0] = c;
        rotate_xy(s);
        rotate_yx(s);
        rotate_yz(s);
        rotate_zy(s);
        rotate_zx(s);
        rotate_xz(s);
}
void rotate_zx(string &s){
    if(zx[s])return;
    zx[s] = true;
    m[s] = true;
        char c = s[1];
        s[1] = s[5];
        s[5] = s[4];
        s[4] = s[3];
        s[3] = c;
        rotate_xy(s);
        rotate_yx(s);
        rotate_yz(s);
        rotate_zy(s);
        rotate_zx(s);
        rotate_xz(s);
}
void rotate_yx(string &s){
        char c = s[4];
        s[4] = s[0];
        s[0] = s[1];
        s[1] = s[2];
        s[2] = c;
}
void rotate_zy(string &s){
        char c = s[5];
        s[5] = s[0];
        s[0] = s[3];
        s[3] = s[2];
        s[2] = c;
}
void rotate_xz(string &s){
        char c = s[1];
        s[1] = s[3];
        s[3] = s[4];
        s[4] = s[5];
        s[5] = c;
}
void solve(string &s){
    m[s] = true;
    rotate_xy(s);
    rotate_yx(s);
    rotate_yz(s);
    rotate_zy(s);
    rotate_zx(s);
    rotate_xz(s);
}
void input(){
  string s;
  cin >> s;

  sort(s.begin(), s.end());
  vector<string>vec;
  do{
    vec.pb(s);
  }while(next_permutation(s.begin(), s.end()));
  int n = vec.size();
  int cnt = 0;

  f(i, n){
     if(!m[vec[i]]){
        solve(vec[i]);++cnt;
     }
  }
  cout << cnt << endl;

}
int main(){
    input();
    return 0;
}

#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <iostream>
using namespace std;

struct roll
{
	int arr[6];
	int l,r,u,d;
	//0 - up
	//1 - down
	//2 - left
	//3 - back
	//4 - right
	//5 - front
	int& operator[](int n)
	{
		return arr[n];
	}
	int operator[](int n) const
	{
		return arr[n];
	}
	roll() {for(int i=0;i<6;i++) arr[i]=i;}
	roll roll_up() const
	{
		roll res;
		res[5]=arr[0];
		res[0]=arr[3];
		res[3]=arr[1];
		res[1]=arr[5];
		res[2]=arr[2];
		res[4]=arr[4];
		return res;
	}
	roll roll_right() const
	{
		roll res;
		res[4]=arr[0];
		res[0]=arr[2];
		res[2]=arr[1];
		res[1]=arr[4];
		res[3]=arr[3];
		res[5]=arr[5];
		return res;
	}
	roll roll_left() const
	{
		return roll_right().roll_right().roll_right();
	}
	roll roll_down() const
	{
		return roll_up().roll_up().roll_up();
	}
	bool operator <(const roll & r) const
	{
		for(int i=0;i<6;i++)
			if(arr[i]!=r[i])
				return arr[i]<r[i];
		return false;
	}
	bool operator ==(const roll &r) const
	{
		for(int i=0;i<6;i++)
			if(arr[i]!=r[i])
				return false;
		return true;
	}
};

vector<roll> same;
string r;

//bool solve(int cur, int visited)
//{
//	if(visited==(1<<24)-1) return true;
//	if(~visited&(1<<same[cur].r))
//	{
//		if(solve(same[cur].r,(1<<same[cur].r)|visited))
//		{
//			r="R"+r;
//			return true;
//		}
//	}
//	if(~visited&(1<<same[cur].u))
//	{
//		if(solve(same[cur].u,(1<<same[cur].u)|visited))
//		{
//			r="U"+r;
//			return true;
//		}
//	}
//
//	return false;
//}

int main()
{
	roll cur,t;
	map<roll,bool> used;
	map<string,bool > counted;
	int gen[23]={0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,1,0,1,0};
	for(int i=0;i<23;i++)
	{
		same.push_back(cur);
		cur=gen[i]?cur.roll_right():cur.roll_up();
	}
	same.push_back(cur);
	//	queue<roll> q;
//	q.push(cur);
//	used[cur]=true;
//	same.push_back(cur);
//	printf("%3s%3s%3s%3s%3s\n","id","U","R","D","L");
//	while(!q.empty())
//	{
//		cur=q.front();
//
//		q.pop();
//		t=cur;
//		for(int i=0;i<4;i++)
//		{
//			t=t.roll_right();
//			if(!used[t])
//			{
//				q.push(t);
//				used[t]=true;
//				same.push_back(t);
//			}
//		}
//		t=cur;
//		for(int i=0;i<4;i++)
//		{
//			t=t.roll_up();
//			if(!used[t])
//			{
//				q.push(t);
//				used[t]=true;
//				same.push_back(t);
//			}
//		}
//
//		cur.r=find(same.begin(),same.end(),cur.roll_right())-same.begin();
//		cur.u=find(same.begin(),same.end(),cur.roll_up())-same.begin();
//		cur.d=find(same.begin(),same.end(),cur.roll_down())-same.begin();
//		cur.l=find(same.begin(),same.end(),cur.roll_left())-same.begin();
//		*find(same.begin(),same.end(),cur)=cur;
////		cout<<(find(same.begin(),same.end(),cur)==same.end())<<endl;
////		printf("%3u%3d%3d%3d%3d\n",find(same.begin(),same.end(),cur)-same.begin(),cur.u,cur.r,cur.d,cur.l);
//	}
//	solve(0,1);
//	cout<<r<<endl;
	string str,temp(6,'a');
	cin>>str;
	vector<int> v;
	for(int i=0;i<6;i++)
		v.push_back(i);
	int res=0;
	do
	{
		for(int i=0;i<6;i++)
			temp[i]=str[same[0][v[i]]];
		if(counted[temp]==false)
			res++;
		else
			continue;
		for(int i=0;i<24;i++)
		{
			for(int j=0;j<6;j++)
				temp[j]=str[v[same[i][j]]];
			counted[temp]=true;

		}
	}
	while(next_permutation(v.begin(),v.end()));
	printf("%d\n",res);
}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <stdio.h>
#include <iterator>
#include <string.h>
#define FOR(i,n) for(int i = 0;i<n;++i)
using namespace std;

char ar[1000][6];

void gen(vector<char> base,int n,int s)
{
	int N = base.size();
	vector<char> t = base;
	FOR(i,N)
	{
		for(int j = s;j<n+s;++j)
			ar[j][6-N] = base[i];
		t = base;
		t.erase(t.begin()+i);
		if(N>1)
			gen(t,n/(N-1),s);
		s+=n;
	}
}

int cmpp(char a1,char a2, char b1, char b2)
{
	if(a1==b1 && a2==b2 && a1==a2)
		return 2;
	if(a1==b1 && a2==b2)
		return 1;
	if(a1==b2 && a2==b1)
		return -1;
	return 0;
}

bool cmp(char a[6],char b[6])
{
	int res = 1;
	int x;
	FOR(i,3)
		if(!(x = cmpp(a[0],a[1],b[0],b[1])))
		{
			int t1 = b[0];
			int t2 = b[1];
			FOR(p,4)
				b[p] = b[p+2];
			b[4] = t1;
			b[5] = t2;
		}
		else
			break;
	int y = cmpp(a[2],a[3],b[2],b[3]);
	int z = cmpp(a[4],a[5],b[2],b[3]);
	if(y)
		z = cmpp(a[4],a[5],b[4],b[5]);
	else
		y = cmpp(a[2],a[3],b[4],b[5]);
	x*=y*z;
	if(!x)
		return false;
	if(x == 2 || x == -2)
		return true;
	if(cmpp(a[0],a[1],a[2],a[3])||cmpp(a[0],a[1],a[4],a[5])
		||cmpp(a[4],a[5],a[2],a[3]))
		return true;
	if(x == -1)
		return false;
	return true;
};

int main()
{
	//freopen("ai.txt","r",stdin);
	//freopen("ao.txt","w",stdout);
	vector<char> base(6);
	FOR(i,6)
		cin >> base[i];
	gen(base,120,0);
	int s = 0;
	bool b;
	FOR(i,720)
	{
		b = true;
		FOR(j,i)
			if(cmp(ar[i],ar[j]))
			{
				b = false;
				break;
			}
		if(b)
		{
			/*FOR(p,6)
				cout << ar[i][p];
			cout << endl;*/
			++s;
		}
	}
	/*FOR(i,100)
	{
		FOR(j,6)
			cout << ar[i][j];
		cout << endl;
	}*/
	cout << s;
	//system("pause");
	return 0;
}

#include <algorithm>
#include <string>
#include <cstdio>
#include <cstring>
#include <set>
using namespace std;
string s,p,pm;
char tmp[16];
set<string> st;
int main() {
	scanf("%s",tmp);
	s=string(tmp);
	int i,j,k,l;
	char t;
	for (i=0; i<720; ++i) {
		pm=s;
		p=s;
		for (j=0; j<4; ++j) {
			for (k=0; k<4; ++k) {
				for (l=0; l<4; ++l) {
					if (p<pm) pm=p;
					t=p[0];
					p[0]=p[1];
					p[1]=p[3];
					p[3]=p[4];
					p[4]=t;
				}
				t=p[0];
				p[0]=p[2];
				p[2]=p[3];
				p[3]=p[5];
				p[5]=t;
			}
			t=p[0];
			p[0]=p[1];
			p[1]=p[3];
			p[3]=p[4];
			p[4]=t;
		}
		st.insert(pm);
		next_permutation(s.begin(),s.end());
	}
	printf("%d\n",st.size());
	return 0;
}

#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <string>
#include <map>
//#include <Windows.h>
using namespace std;
set<string> st;
void r1(string &s)
{
    swap(s[0], s[1]);
    swap(s[1], s[2]);
    swap(s[2], s[3]);
}
void r2(string &s)
{
    swap(s[0], s[4]);
    swap(s[4], s[2]);
    swap(s[2], s[5]);
}

void rGen(string s)
{
    st.insert(s);
    r1(s);
    st.insert(s);
    r1(s);
    st.insert(s);
    r1(s);
    st.insert(s);
    r1(s);
}

void fullGen(string s)
{
    r2(s);
    rGen(s);
    r2(s);
    rGen(s);
    r2(s);
    rGen(s);
    r2(s);
    rGen(s);
    r1(s);
    r2(s);
    rGen(s);
    r2(s);
    r2(s);
    rGen(s);
}

int main() {
    string s;// = "123123";

#ifndef ONLINE_JUDGE
    freopen("1.txt", "r", stdin);
#endif
    cin >> s;
    int res = 0;
    for (int i = 0; i < 720; i++)
    {
        int o = st.size();
        fullGen(s);
        if (st.size() > o)
            res++;
        next_permutation(s.begin(), s.end());
    }
    cout << res;
    return 0;
}

#include <bits/stdc++.h>

#define MAXN 10

using namespace std;

struct state {
    string a;
};

state init;
set <string> ans, sol;

/*
 3
 2
514
 0
*/

state rotate_horiz( state tmp ) {
    /*
     3      5
     2      2
    514 => 143
     0      0
    */
    state ret = tmp;
    ret.a[1] = tmp.a[4];
    ret.a[3] = tmp.a[5];
    ret.a[4] = tmp.a[3];
    ret.a[5] = tmp.a[1];
    return ( ret );
}

state rotate_vert( state tmp ) {
    /*
     3      2
     2      1
    514 => 504
     0      3
    */
    state ret = tmp;
    for ( int i = 0; i < 4; ++i ) {
        ret.a[i] = tmp.a[(i+1)%4];
    }
    return ( ret );
}

void solve( state tmp ) {

    if ( sol.find( tmp.a ) != sol.end() ) {
        return;
    }

    sol.insert( tmp.a );

    solve( rotate_horiz(tmp) );
    solve( rotate_vert(tmp) );

}

int main( ) {

    cin >> init.a;

    sort( init.a.begin(), init.a.end() );

    do {
        sol.clear();
        solve( init );
        if ( ans.find( *sol.begin() ) == ans.end() ) {
            ans.insert( *sol.begin() );
        }
    }while ( next_permutation( init.a.begin(), init.a.end() ) );

    printf( "%d\n", (int)ans.size() );

    return 0;

}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
template<class T> T gcd(T a,T b){return a==0?b:gcd(b%a,a);}
template<class T> string tostring(T a){ostringstream os;os<<a;return os.str();}
int toint(string a){istringstream is(a);int p;is>>p;return p;}
long long toll(string a){istringstream is(a);long long p;is>>p;return p;}

map<string,int> aa;
void dfs(string s,int k)
{
	if(aa.find(s)!=aa.end())return;
	aa[s]=k;
	string ss=s;
	ss[0]=s[3];
	ss[1]=s[2];
	ss[2]=s[0];
	ss[3]=s[1];
	dfs(ss,k);
	ss=s;
	ss[0]=s[5];
	ss[1]=s[4];
	ss[4]=s[0];
	ss[5]=s[1];
	dfs(ss,k);
}

int main()
{
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	int k=0;
	do
	{
		dfs(s,k++);
	}while(next_permutation(s.begin(),s.end()));
	set<int> se;
	for(map<string,int>::iterator it=aa.begin();it!=aa.end();it++)
	{
		se.insert(it->second);
	}
	cout<<se.size()<<endl;
}

#include <bits/stdc++.h>

#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(ll i=n;i<=N;++i)
#define rap(i,n,N) for(ll i=n;i>=N;--i)
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define plll pair<ll,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl "\n"
const int MAX = 1e3+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll INF = 1e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 450;

int ans;
string s,t;
set<string> st;

int main(){
//	cout<<fixed<<setprecision(15);
//    freopen("class_treasurer.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>s;
    sort(all(s));
    do {
    	t = s;
    	if(!st.count(t)){
    		++ans;
//    		cout<<t<<endl;
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			reverse(t.begin()+1,t.begin()+5);
			swap(t[0],t[5]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
			reverse(t.begin()+1,t.begin()+5);

			swap(t[0],t[1]), swap(t[5],t[3]);
			reverse(t.begin()+1,t.begin()+5);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			reverse(t.begin()+1,t.begin()+5);
			swap(t[0],t[5]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
			reverse(t.begin()+1,t.begin()+5);
			reverse(t.begin()+1,t.begin()+5);
			swap(t[0],t[1]), swap(t[5],t[3]);

			swap(t[0],t[2]), swap(t[5],t[4]);
			reverse(t.begin()+1,t.begin()+5);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
			reverse(t.begin()+1,t.begin()+5);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
		}
	}while(next_permutation(all(s)));
	cout<<ans<<endl;
	return 0;
}

#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

char gems[10];
string per;
map<char, int> mapa;
map<string, int> map_per;

int start_vals[11] = {1,1,2,2,2,3,6,5,8,15,30};
string start_vals_s[11] = {"6","15","24","33","114","123","222","1113","1122","11112","111111"};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    for(int i=0;i<11;i++)
        map_per[start_vals_s[i]] = start_vals[i];

    cin >> gems;

    for (int i = 0; i < 6; i++)
        mapa[gems[i]] += 1;

    for(auto e: mapa)
        per += (char)(e.second + '0');

    sort(per.begin(), per.end());
    cout<<map_per[per]<<"\n";
}

#include<iostream>
#include<vector>
#include<stack>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
//----------------------

string str;
set<string>s;
//----------------------
void read();
void write();
//----------------------
int main(){
#ifndef ONLINE_JUDGE
    freopen("a.in","rt",stdin);
    freopen("a.out","wt",stdout);
#endif
    read();

    //--решение--
    srand( (unsigned)time( NULL ) );
    set<string>s_tmp;
    string tmp;
    for(int i=0;i<720;++i){
        tmp=str;
        s_tmp.clear();
        for(int j=0;j<2000;++j){
            if(rand()%2){
                char t=tmp[3];
                tmp[3]=tmp[2];
                tmp[2]=tmp[1];
                tmp[1]=tmp[0];
                tmp[0]=t;
            }else{
                char t=tmp[5];
                tmp[5]=tmp[2];
                tmp[2]=tmp[4];
                tmp[4]=tmp[0];
                tmp[0]=t;
            }
            s_tmp.insert(tmp);
        }
        s.insert(s_tmp.begin()->c_str());
        next_permutation(str.begin(),str.end());
    }

    write();
    return 0;
}
//----------------------
void read(){
    cin>>str;
}
//----------------------
void write(){
    cout<<s.size();
}
//----------------------

#include <bits/stdc++.h>

void rotate_x(std::string& a) {
    char c = a[1]; a[1] = a[2]; a[2] = a[3]; a[3] = a[4]; a[4] = c;
}

void rotate_y(std::string& a) {
    char c = a[0]; a[0] = a[1]; a[1] = a[5]; a[5] = a[3]; a[3] = c;
}

void rotate_z(std::string& a) {
    char c = a[0]; a[0] = a[2]; a[2] = a[5]; a[5] = a[4]; a[4] = c;
}

bool is_equal(std::string& a, std::string& b) {
    std::string c = b;
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 4; ++k) {
                if (a == c) {
                    return true;
                }
                rotate_z(c);
            }
            rotate_y(c);
        }
        rotate_x(c);
    }
    return false;
}

int main(void) {
    std::string str;
    std::cin >> str;
    std::sort(str.begin(), str.end());
    std::vector<std::string> unique;
    do {
        bool fl = true;
        for (int i = 0; i < unique.size(); ++i) {
            if (is_equal(unique[i], str)) {
                fl = false;
                break;
            }
        }
        if (fl) {
            unique.push_back(str);
        }
    } while (std::next_permutation(str.begin(), str.end()));
    std::cout << unique.size() << std::endl;
    return 0;
}

/*
	Author: Dinesh Verra
	College: ABV-IIITM
	Date: 07/07/2020
*/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cu continue
#define br break
#define pb push_back
#define eb emplace_back
#define mod 1000000007
#define inf 1000000000
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > >
#define F first
#define S second
#define vll vector <ll>
#define vpll vector <pll>
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define all(v) v.begin(),v.end()
#define nl cout<<'\n'

template <typename A1>
void prn(A1&& arg)
{
	cout<<arg<<'\n';
}
template <typename A1, typename... A>
void prn(A1&& arg, A&&... args)
{
	cout<<arg<<' ';
	prn(args...);
}

ll dp[][6]={
    {0,1,2,3,4,5},
    {0,2,3,4,1,5},
    {0,3,4,1,2,5},
    {0,4,1,2,3,5},
    {5,3,2,1,4,0},
    {5,2,1,4,3,0},
    {5,1,4,3,2,0},
    {5,4,3,2,1,0},

    {1,2,0,4,5,3},
    {1,0,4,5,2,3},
    {1,4,5,2,0,3},
    {1,5,2,0,4,3},
    {3,4,0,2,5,1},
    {3,0,2,5,4,1},
    {3,2,5,4,0,1},
    {3,5,4,0,2,1},

    {2,0,1,5,3,4},
    {2,1,5,3,0,4},
    {2,5,3,0,1,4},
    {2,3,0,1,5,4},
    {4,5,1,0,3,2},
    {4,1,0,3,5,2},
    {4,0,3,5,1,2},
    {4,3,5,1,0,2},
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifndef ONLINE_JUDGE
	freopen("/home/dinesh_verra/cpp/input.txt","r",stdin);
	// freopen("/home/dinesh_verra/cpp/output.txt","w",stdout);
	#endif

	string s,tmp,tmp2;
	cin>>s;
	sort(all(s));
	set <string> q,q2;
	do
	{
		tmp=s;
		if(!q2.count(tmp))
		{
			ll cnt=0;
			for(ll i=0;i<24;i++)
			{
				for(ll j=0;j<6;j++)
					tmp[j]=s[dp[i][j]];
				if(!q2.count(tmp))
					cnt++;
			}
			if(cnt==24)
				q.insert(s);
			for(ll i=0;i<8;i++)
			{
				for(ll j=0;j<6;j++)
					tmp[j]=s[dp[i][j]];
				q2.insert(tmp);
			}
		}

	}
	while(next_permutation(all(s)));
	prn(q.size());
}

/*

___▒▒▒▒______▒▒▒▒▒▒▒▒
__▒▒░░░░▒▒▒▒▒▒▒░░░░▒▒
_▒▒░░░░░░▒▒▒▒▒░░░__░▒▒
▒▒░___░░▒▒▒▒▒▒▒░░__░▒▒
▒▒░__░▒▒▒▒▒▒▒▒▒▒▒_░▒
_▒░░▒▒▒▒▒▒█▒▒▒▒▒█▒▒
___▒▒▒▒▒▒░██▒▒▒▒██_▒___▒▒___▒▒
___▒▒▒▒▒░░░░███░░░▒▒___▒▒__▒▒
___▒▒▒▒▒░░___███____▒▒___▒▒_▒▒
____▒▒░░__▀▄▄▄▄▄▄▀░▒_____▒▒▒▒▒
_____▒▒▒░_____▀▀_░▒▒______▒▒▒▒▒▒
___▒▒▒░▒░░░▒▒▒░_▒▒▒▒▒▒▒▒▒▒▒
__▒▒▒░▒▒▒▒▒░░░▒░▒▒▒▒▒▒▒▒▒
_▒▒▒░▒▒▒▒___▒▒__▒▒▒▒▒▒▒▒▒
_▒▒▒░▒░░_________░▒▒▒▒

*/
#include<bits/stdc++.h>
using namespace std;
#define ll                  long long
#define ld                  long double
#define ull                 unsigned long long
#define f                   first
#define se                  second
#define SpeedForce          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sqr(x)              ((x)*(x))
#define forn(i, n)          for(int i=0;i<n;++i)
#define forl(i, a, b)       for(int i=(a);i<=(b);++i)
#define ford(i, a, b)       for(int i=(a);i>=(b);--i)
#define cno                 cout<<"NO";return 0;
#define cye                 cout<<"YES";return 0;
#define pb                  push_back
#define mp                  make_pair
#define all(a)              (a).begin(), (a).end()
#define pb1                 pop_back
#define fill(a, x)          memset(a, x, sizeof(a))

typedef pair< int, int > pii;
typedef map< int, int > mii;
typedef vector< int > vi;
typedef pair< char, int > pci;
typedef pair< pii, int > ppiii;
typedef map <string, int> msi;
typedef map <char, int> mci;

const ld pi = 3.141592653589793238462643, eps = 1e-12;
const ull mod = 1e9+7;
const int MAXN = 5010;

int fast_pow(int a, int b){
	int res = a, ret = 1;
	while(b>0){
		if(b%2)
			ret = (ret*res)%mod;
		res = (res*res)%mod;
		b/=2;
	}
	return ret;
}

ll fact(int x) {
    ll res = 1;
    for (int i = 2; i <= x; i++)
            res *= i;
    return res;
}

string s;
mci m;

int main() {
    SpeedForce
    cin >> s;
    forn(i, s.size()) m[s[i]]++;
    vi all;
    for (mci::iterator it = m.begin(); it != m.end(); it++)
        all.pb(it->second);
    sort(all.begin(), all.end());
    if (all.size() == 1) cout << 1 << endl;
    else if (all.size() == 2) {
        if(all[1] == 5) cout << 1 << endl;
        else if (all[1] == 4) cout << 2 << endl;
        else cout << 2 << endl;
    }
    else if (all.size() == 3) {
        if(all[2] == 4) cout << 2 << endl;
        else if (all[2] == 3) cout << 3 << endl;
        else cout << 6 << endl;
    }
    else if (all.size() == 4) {
        if (all[3] == 3) cout << 5 << endl;
        else cout << 8 << endl; }
    else if (all.size() == 5) cout << 15 << endl;

    else cout << 30 << endl;
    return 0;
}

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long LL;
const double eps = 1e-9;
const int inf = 1000000002;
inline int Str2Int(string s) { return atoi(s.c_str()); }
inline string Int2Str(int i) { ostringstream ous; ous << i; return ous.str(); }

int dx[7] = {0, 2, 3, 4, 1, 5, 6};
int dy[7] = {0, 5, 2, 6, 4, 3, 1};
int dz[7] = {0, 1, 5, 3, 6, 4, 2};

const int maxn = 100000;

void perm(char a[7], int p[7]) {
    char c[7];
    for (int i = 1; i <= 6; ++i)
        c[i] = a[i];
    for (int i = 1; i <= 6; ++i)
        a[i] = c[p[i]];
}

int a[7];
char b[7];
char ans[maxn][7];

int main() {
 //   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

    string s;
    cin >> s;
    for (int i = 1; i <= 6; ++i)
        a[i] = i;
    int k = 0;
    do {
        for (int i = 1; i <= 6; ++i)
            b[i] = s[a[i]-1];
        bool prov = false;
        for (int j = 0; j < k; ++j) {
            for (int q1 = 0; q1 < 4; ++q1) {
                for (int q2 = 0; q2 < 4; ++q2) {
                    for (int q3 = 0; q3 < 4; ++q3) {
                        bool p = true;
                        for (int i = 1; i <= 6; ++i) {
                            if (ans[j][i] != b[i])
                                p = false;
                        }
                        if (p)
                            prov = true;
                        perm(b, dz);
                    }
                    perm(b, dy);
                }
                perm(b, dx);
            }
        }
        if (!prov) {
            for (int i = 1; i <= 6; ++i)
                ans[k][i] = b[i];
            ++k;
        }
    } while (next_permutation(a+1, a+7));

    cout << k << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

set< string > s;
string v;

map<string,bool> m;

void rot (string x) {
    if ( m[x] == 1 ) return;
    m[x] = 1;
    s.erase(x);
    string y = x;
    y[0] = x[1];
    y[1] = x[2];
    y[2] = x[3];
    y[3] = x[0];
    rot (y);
    y = x;
    y[1] = x[4];
    y[4] = x[3];
    y[3] = x[5];
    y[5] = x[1];
    rot (y);
    return;
}

int main () {

    cin >> v;

    for (int i=0; i<1000; i++) {
        next_permutation(v.begin(), v.end() );
        s.insert(v);
    }

    int ans = 0;
    while (s.size() > 0) {
        ans++;
        rot( *s.begin() );
    }

    cout << ans << endl;
}

#include <stdio.h>
#include <set>
#include <string>
#include <algorithm>

using namespace std;

char cad[1000];
char aux[1000];
set<string> seto;

void cambia()
{
    int auxi = aux[0];
    aux[0] = aux[1];
    aux[1] = aux[2];
    aux[2] = aux[3];
    aux[3] = auxi;
}

int main()
{
    gets(cad);
    cad[5] = 0;
    sort(cad, cad + 5);
    int cont = 0;
    do
    {
        string str(cad);
        if (seto.find(str) == seto.end())
        {
            cont++;
            for (int i = 0; i < 5; i++)
            {
                aux[i] = cad[i];
            }

            for (int i = 0; i < 4; i++)
            {
                seto.insert(string(aux));
                cambia();
            }

        }

    } while (next_permutation(cad, cad + 5));

    printf("%d", cont);
}

#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;

map <char,int> p;
string t;
string s="ROYGBV";

int main()
{
    string str;
    int i;
    while(cin >> str)
    {
        p.clear();
        t.clear();
        for( i=0; i<str.size(); ++i)
        {
            p[str[i]]++;
        }
        for( i=0; i<s.size(); ++i)
        {
            if(p[s[i]]!=0) t+=p[s[i]]+'0';
        }
        sort(&t[0],&t[t.size()]);
        if(t=="6") printf("1\n");
        else if(t=="15") printf("1\n");
        else if(t=="24") printf("2\n");
        else if(t=="33") printf("2\n");
        else if(t=="114") printf("2\n");
        else if(t=="123") printf("3\n");
        else if(t=="222") printf("4\n");
        else if(t=="1113") printf("4\n");
        else if(t=="1122") printf("5\n");
        else if(t=="11112") printf("10\n");
        else if(t=="111111") printf("30\n");
    }
    return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>

#define FOR(i,a,n) for(int i=a,_n(n);i<_n;++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int dir[][6]={
    {0,1,2,3,4,5},
    {1,0,4,3,2,5},
    {3,5,1,4,0,2},
    {5,3,0,4,1,2},
    {4,2,0,5,1,3},
    {2,4,1,5,0,3}
};
int main()
{
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    set<string> exist;
    int ans = 0;
    do
    {
        if(exist.count(s)) continue;
        REP(i,6)
        {
            REP(j,4)
            {
                string st;
                st += s[dir[i][0]];
                st += s[dir[i][1]];
                REP(k,4) st+=s[dir[i][(k+j)%4+2]];
                exist.insert(st);
            }
        }
        puts(s.c_str());
        ans++;
    }while(next_permutation(s.begin(),s.end()));
    printf("%d\n",ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
//#define f first
//#define s second
const int N = 3e5 + 5;
const double pi = acos(-1);
const int mod = 1e9 + 7;

ll fastpow(ll b, ll e) {
    if (!e) return 1;
    ll ret = fastpow(b, e / 2);
    ret = (ret * ret) % mod;
    if (e % 2) ret = (ret * b) % mod;
    return ret;
}
ll mi(int x) {
    return fastpow(x, mod - 2);
}
int main()
{
    map<char, int> sc;
    string s;
    cin >> s;
    for (int i = 0; i < 6; i++)
        sc[s[i]]++;
    int num = sc.size() - 1;
    if (!num) puts("1");
    else printf("%d\n", num * (num + 1));
    return 0;
}

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<iomanip>
#include<set>

using namespace std;
const int maxn=100000;

int main(){
    char f[6];
    cin>>f;
    set<char>M;
    for(int i=0;i<6;++i)
        M.insert(f[i]);
    if(M.size()==1)cout<<1<<endl;
    else cout<<M.size()*(M.size()-1)<<endl;
    return 0;
}

#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

string toStr(char c)
{
	string t;
	t+=c;
	return t;
}
int main()
{
	string s;
	cin>>s;
	vector<char>a;
	for(int i=0;i<(int)s.length();i++)
	{
		a.push_back(s[i]);
	}
	sort(a.begin(),a.end());

	map<string,int>p;
	int count = 0;
	do
	{
		string t;
		for(int i=0;i<(int)a.size();i++)
		{
			t+=a[i];
		}
		if(p.find(t)==p.end())
		{
			p[t] = 1;
			count++;
			string m = toStr(a[0]) + toStr(a[1]) + toStr(a[2]) + toStr(a[3]) + toStr(a[4]) + toStr(a[5]);
			p[m] = 1;
			m = toStr(a[1]) + toStr(a[0]) + toStr(a[3]) + toStr(a[2]) + toStr(a[4]) + toStr(a[5]);
			            p[m] = 1;
			 m = toStr(a[2]) + toStr(a[3]) + toStr(a[4]) + toStr(a[5]) + toStr(a[0]) + toStr(a[1]);
			            p[m] = 1;
			 m = toStr(a[3]) + toStr(a[2]) + toStr(a[5]) + toStr(a[4]) + toStr(a[0]) + toStr(a[1]);
			                        p[m] = 1;
		 m = toStr(a[4]) + toStr(a[5]) + toStr(a[0]) + toStr(a[1]) + toStr(a[2]) + toStr(a[3]);
		                                     p[m] = 1;
		  m = toStr(a[5]) + toStr(a[4]) + toStr(a[1]) + toStr(a[0]) + toStr(a[2]) + toStr(a[3]);
		                                     p[m] = 1;

		}
	}while(next_permutation(a.begin(),a.end()));

	int b[256]={0};
	for(int i=0;i<s.length();i++)
	{
		b[s[i]]++;
	}
	int temp =0;
	for(int i=0;i<256;i++)
	{
		if(b[i]>0)
			temp++;
	}
	cout<<(count/temp)<<endl;
	return 0;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)-v.begin()
#define ub(v,val) upper_bound(v.begin(),v.end(),val)-v.begin()
#define lb(v,val) lower_bound(v.begin(),v.end(),val)-v.begin()
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9 + 7;
int INF = 1e6;

ll n, m;

int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	char s[6];
	map<char, ll> dummy;
	rep(i, 6) {
		cin >> s[i];
		dummy[s[i]]++;
	}
	ll cnt = 0;
	if (dummy.size() == 6)
		cnt = 30;
	if (dummy.size() == 5) {
		cnt = 15;
	}
	if (dummy.size() == 4) {
		ll a[4];
		k = 0;
		for (auto u : dummy)
			a[k++] = u.se;
		sort(a, a + 4);
		if (a[3] == 2)
			cnt = 1 + 2 + 1 + 2;
		if (a[3] == 3)
			cnt = 5;
	}
	if (dummy.size() == 3) {
		ll a[3];
		k = 0;
		for (auto u : dummy)
			a[k++] = u.se;
		sort(a, a + 3);
		if (a[2] == 2)
			cnt = 4;
		if (a[2] == 3)
			cnt = 4;
		if (a[2] == 4)
			cnt = 2;
	}
	if (dummy.size() == 1)
		cnt = 1;
	if (dummy.size() == 2) {
		ll a[2];
		k = 0;
		for (auto u : dummy)
			a[k++] = u.se;
		sort(a, a + 2);
		if (a[1] == 3)
			cnt = 2;
		if (a[1] == 4)
			cnt = 2;
		if (a[1] == 5)
			cnt = 1;
	}

	cout << cnt;
	return 0;
}

#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
int main()
{
    char str[8];
    int ct[7],ans[7],res;
    map<char,int>h;
    h['R']=1;
    h['O']=2;
    h['Y']=3;
    h['G']=4;
    h['B']=5;
    h['V']=6;
    while(scanf("%s",str)==1)
    {
      memset(ct,0,sizeof(ct));
      memset(ans,0,sizeof(ans));
      for(int i=0;i<6;i++)
      {
          ct[h[str[i]]]++;
      }
      for(int i=1;i<=6;i++)
      {
         // printf("%d\n",ct[i]);
          if(ct[i])
          ans[ct[i]]++;
      }

      if(ans[1]==6)
      res=30;
      else if(ans[1]==4&&ans[2]==1)
      res=18;
      else if(ans[1]==3&&ans[3]==1)
      res=6;
      else if(ans[1]==2)
      {
          if(ans[2]==2)
          res=10;
          else res=2;
      }else if(ans[1]==1)
      {
          if(ans[2]==1&&ans[3]==1)
          res=3;
          else res=1;
      }else if(ans[6]==1)
      res=1;
      else if(ans[3]==2)
      res=3;
      else if(ans[2]==3)
      res=6;
      else if(ans[2]==1&&ans[4]==1)
      res=2;
      printf("%d\n",res);
    }

    return 0;
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define pb push_back
#define mp make_pair
#define tr(s,i) for(vector<int>::iterator i=s.begin();i!=s.end();++i)
typedef vector<int> vi;
typedef vector<int>::iterator vit;
typedef map<string, int> msi;
typedef priority_queue<int> maxh;
typedef priority_queue<int, vector<int>, greater<int> > minh;

int a[9]; // BGORVY

int A(int n) {
    int s = 1;
    for (int i = 1; i <= n; s *= i++);
    return s;
}

int main() {
    int i, n, t;
    string s;
    cin >> s;
    for (i = 0; i < 6; i++) {
        char c = s[i];
        switch (c + 32) {
            case 'b': a[1]++; break;
            case 'g': a[2]++; break;
            case 'o': a[3]++; break;
            case 'r': a[4]++; break;
            case 'v': a[5]++; break;
            case 'y': a[6]++; break;
        }
    }
    sort(a, a + 9, greater<int>());
    if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1 && a[4] == 1 && a[5] == 1) {
        cout << 30 << endl;
    } else if (a[0] == 2 && a[1] == 1 && a[2] == 1 && a[3] == 1 && a[4] == 1 && a[5] == 0) {
        cout << 12 << endl;
    } else if (a[0] == 2 && a[1] == 2 && a[2] == 1 && a[3] == 1 && a[4] == 0 && a[5] == 0) {
        cout << 1+2+2 << endl;
    } else if (a[0] == 2 && a[1] == 2 && a[2] == 2 && a[3] == 0 && a[4] == 0 && a[5] == 0) {
        cout << 1 + 3*1 + 2 << endl;
    } else if (a[0] == 3 && a[1] == 1 && a[2] == 1 && a[3] == 1 && a[4] == 0 && a[5] == 0) {
        cout << 3 + 2 << endl;
    } else if (a[0] == 3 && a[1] == 2 && a[2] == 1 && a[3] == 0 && a[4] == 0 && a[5] == 0) {
        cout << 3 << endl;
    } else if (a[0] == 4 && a[1] == 1 && a[2] == 1) {
        cout << 2 << endl;
    } else if (a[0] == 4 && a[1] == 2) {
        cout << 2 << endl;
    } else if (a[0] == 5 && a[1] == 1) {
        cout << 1 << endl;
    } else if (a[0] == 3 && a[1] == 3) {
        cout << 2 << endl;
    } else if (a[0] == 6) {
        cout << 1 << endl;
    }
    return 0;
}

/*
    The bigger the rocks
                       the greater the chance
                                            to find high value tokens!! */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,t,q,z,x,y,k,m;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
struct edge
{
    lli first,second,third;
};
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,l,r;
//string s[100005];
map<lli,lli> nm;
//map<lli,lli> vis;
lli ii=1;
lli vis[1000005];
lli p[24][6];
int main()
{
string s;
lli p[25][7]={{1,2,3,4,5,6},
   {1,2,5,6,4,3},
   {1,2,4,3,6,5},
   {1,2,6,5,3,4},
   {2,1,3,4,5,6},
   {2,1,5,6,4,3},
   {2,1,4,3,6,5},
   {2,1,6,5,3,4},
   {3,4,2,1,5,6},
   {3,4,5,6,1,2},
   {3,4,1,2,6,5},
   {3,4,6,5,2,1},
   {4,3,2,1,5,6},
   {4,3,5,6,1,2},
   {4,3,1,2,6,5},
   {4,3,6,5,2,1},
   {5,6,2,1,3,4},
   {5,6,3,4,1,2},
   {5,6,1,2,4,3},
   {5,6,4,3,2,1},
   {6,5,2,1,3,4},
   {6,5,3,4,1,2},
   {6,5,1,2,4,3},
   {6,5,4,3,2,1}
};

cin>>s;
lli d=721;
map<lli,lli> ml;
ml[1]=6;
ml[6]=1;
ml[2]=5;
ml[5]=2;
ml[3]=4;
ml[4]=3;
lli cnt=0;
map<string,lli> mk;
set<string> ss;
sort(s.begin(),s.end());
while(d--)
{
    if(ss.count(s)==0)
    {
    cnt++;
    for(int i=1;i<=24;i++)
    {
        string dd="\0";
        for(int j=0;j<6;j++)
        dd+=(s[p[i-1][j]-1]);
        //cout<<dd<<" "<<s<<endl;
        ss.insert(dd);
    }
    }
    //cout<<s<<endl;
    next_permutation(s.begin(),s.end());
}

cout<<cnt;
}

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int cnt = 0;
set <string> ans;

void do_cycle(string s)
{
     for (int i = 0;i < 4; ++i){
         //cout << s << endl;
         if (ans.find(s) != ans.end())
            ans.erase(ans.find(s));
         char c = s[3];
         s[3] = s[2];
         s[2] = s[1];
         s[1] = s[0];
         s[0] = c;
     }
}

int main(){
    string s, ss = "xxxxxx";
    string rot[3] = {"012345", "042531", "415320"};
    cin >> s;
    do{
       for (int i = 0; i < 3;++i){
           for (int j = 0;j < 6;++j)
               ss[j] = s[rot[i][j] - '0'];
           do_cycle(ss);
           swap(ss[4], ss[5]);
           swap(ss[1], ss[3]);
           do_cycle(ss);
       }
       ans.insert(s);
    }
    while (next_permutation(s.begin(), s.end()));
    cout << ans.size() << endl;
    cin >> s;
    return 0;
}

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<iomanip>
#include<set>

using namespace std;
const int maxn=100000;

int main(){
    char f[6];
    cin>>f;
    set<char>M;
    for(int i=0;i<6;++i)
        M.insert(f[i]);
    switch(M.size()){
        case 1: cout<<1<<endl; break;
        case 6: cout<<30<<endl; break;
        case 2: {
            char a=f[0];
            int x=1;
            for(int i=1;i<6;++i)
                if(f[i]==a)x++;
            if(x==1||x==5)cout<<1<<endl;
            else cout<<2<<endl;
            break;
        }
        case 3:{
            char a=f[0],b;
            int x=1,y=0;
            for(int i=1;i<6;++i){
                if(f[i]==a)x++;
                else if(!y)b=f[i],y++;
                else if(f[i]==b)y++;
            }
            if(x==y)cout<<3<<endl;
            else cout<<2<<endl;
            break;
        }
        case 4:{
            char a,b,c;
            int x=0,y=0,z=1;
            for(int i;i<6;++i){
                if(f[i]==a)z++;
                else if(!x||f[i]==b)++x,b=f[i];
                else if(!y||f[i]==c)++y,c=f[i];
            }
            if(x==3||y==3||x+y==3)cout<<5<<endl;
            else cout<<8<<endl;
            break;
        }
        case 5:cout<<15<<endl;break;
    }
    return 0;
}

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 100005;
int s[27];
char a[N];
int main() {
    scanf("%s", a);
    for(int i = 0; i < 6; i ++) {
        if(a[i] == 'R') s[0]++;
        else if(a[i] == 'O') s[1]++;
        else if(a[i] == 'Y') s[2]++;
        else if(a[i] == 'G') s[3]++;
        else if(a[i] == 'B') s[4]++;
        else if(a[i] == 'V') s[5]++;
    }
    sort(s, s+6);
    int sum = 0;
    for(int i = 0; i < 6; i ++) {
//      printf("%d ", s[i]);
        sum = sum * 10 + s[i];
    } //puts("");
//  printf("%d\n", sum);
    if(sum == 111111) puts("30");
    else if(sum == 11112) puts("15");
    else if(sum == 1113) puts("5");
    else if(sum == 1122) puts("4");
    else if(sum == 114) puts("2");
    else if(sum == 123) puts("3");
    else if(sum == 15) puts("1");
    else if(sum == 222) puts("3");
    else if(sum == 24) puts("2");
    else if(sum == 33) puts("2");
    else if(sum == 6) puts("1");

    return 0;
}

/*
codeforces beta round 78 division 2
problem c
*/

#include <iostream>
#include <set>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned char uc;
string s;
set<string> valid;

vector<uc> ans(4);
bool visit[6]={false};

int main(){
	int cnt=0;
	cin>>s;
	sort(s.begin(),s.end());
	for(int i=1;i<6;i++){
		visit[i]=true;
		int k;
		for(k=1;visit[k];k++);
		visit[k]=true;
		for(int i1=1;i1<6;i1++)if(!visit[i1]){
			visit[i1]=true;
			for(int i2=1;i2<6;i2++)if(!visit[i2]){
				visit[i2]=true;
				for(int i3=1;i3<6;i3++)if(!visit[i3]){
					string tmp;
					tmp.push_back(s[i]);
					tmp.push_back(s[i1]);
					tmp.push_back(s[i2]);
					tmp.push_back(s[i3]);
					//cout<<tmp<<"\t"<<cnt++<<endl;
					valid.insert(tmp);
				}
				visit[i2]=false;
			}
			visit[i1]=false;
		}
		visit[k]=false;
		visit[i]=false;
	}
	cout<<valid.size()<<endl;
	return 0;
}

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

struct cubo {
    int cara[6];
};
bool operator == (cubo A, cubo B){
    forn(i, 6){
        if(A.cara[i] != B.cara[i])
            return false;
    }
    return true;
}

cubo inicial;
vector<cubo> v;
string s;

int valor(char c){
    string q = "ROYGBV";
    forn(i, q.size()){
        if(c == q[i]) return i;
    }
    while(true);
}

void rotateX(cubo &A){
    int a = A.cara[0];
    int b = A.cara[2];
    int c = A.cara[4];
    int d = A.cara[5];
    A.cara[0] = d;
    A.cara[2] = a;
    A.cara[4] = b;
    A.cara[5] = c;
}
void rotateY(cubo &A){
    int a = A.cara[1];
    int b = A.cara[2];
    int c = A.cara[3];
    int d = A.cara[5];
    A.cara[1] = d;
    A.cara[2] = a;
    A.cara[3] = b;
    A.cara[5] = c;
}

bool compare(cubo A, cubo B){
    forn(i, 4){
        rotateX(A);
        if(A == B) return true;
        forn(j, 4){
            rotateY(A);
            if(A == B) return true;
            forn(k, 4){
                rotateX(A);
                if(A == B) return true;
            }
        }
    }
}

int main(){
    cin >> s;
    forn(i, 6){
        inicial.cara[i] = valor(s[i]);
    }
    int tc = 720;
    while(tc--){
        bool nuevo = true;
        forn(i, v.size()){
            if( compare(v[i], inicial) )
                nuevo = false;
        }
        if(nuevo){
            v.push_back(inicial);
        }
        next_permutation(inicial.cara, inicial.cara+6);
    }
    printf("%d\n", v.size());
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fstream>
#include <algorithm>
#include <math.h>

using namespace std;

char str[10];
int n,s[10];
int ans[1000000];

int main()
{
  //  freopen("in.txt","r",stdin);
    cin>>str;
    bool temp;
    n=0;
    ans[111111]=30; ans[11112]=18;
    ans[1122]=5; ans[222]=4;
    ans[1113]=8; ans[123]=3;
    ans[33]=2; ans[114]=2;
    ans[24]=2; ans[15]=1; ans[6]=1;
    for(int i=0;str[i];i++)
    {
        temp=true;
        for(int j=0;j<i;j++)
        {
            if(str[j]==str[i])
            {
                temp=false;
                break;
            }
        }
        if(!temp) continue;
        int k=1;
        for(int j=i+1;str[j];j++)
        {
            if(str[i]==str[j])
            {
               k++;
            }
        }
        s[n++]=k;
    }
    sort(s,s+n);
    int k=0;
    for(int i=0;i<n;i++)
    {
        k*=10;
        k+=s[i];
    }
    printf("%d\n",ans[k]);
    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

#define MP make_pair
#define VI vector<int>
#define PI 3.14159265358979
#define LL long long
using namespace std;

set<string> ss;
string str;

void r1( string &s )
{
	char t = s[0]; s[0] = s[1], s[1] = s[2], s[2] = s[3], s[3] = t;
}

void r2( string &s )
{
	char t = s[1]; s[1] = s[4], s[4] = s[3], s[3] = s[5], s[5] = t;
}

void r3( string &s )
{
	char t = s[0]; s[0] = s[4], s[4] = s[2], s[2] = s[5], s[5] = t;
}

void check( string s )
{
	string best = s;
	for( int i = 0; i < 4; ++ i )
	{
		r1( s );
		if( best > s ) best = s;
		for( int j = 0; j < 4; ++ j )
		{
			r2( s );
			if( best > s ) best = s;
			for( int k = 0; k < 4; ++ k )
			{
				r3( s );
				if( best > s ) best = s;
			}
		}
	}
	ss.insert( best );
}

int main()
{
	freopen ( "in.txt", "r", stdin );
	//freopen ( "out.txt", "w", stdout );
	string str;
	while( cin >> str )
	{
		ss.clear();
		sort( str.begin(), str.end() );
		do
		{
			check( str );
		}while( next_permutation( str.begin(), str.end() ) );
		printf( "%d\n", ss.size() );
	}

	return 0;
}

#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
int main()
{
    string s="ROYGBV",str;
    int m[6],count[7],i;
    while(cin>>str)
    {
        memset(m,0,sizeof(m));
        memset(count,0,sizeof(count));
        for(i=0;i<6;++i)
        {
            m[s.find(str[i])]++;
        }
        for(i=0;i<6;++i)
        {
            count[m[i]]++;
        }
        if(count[6]==1||count[5]==1) cout<<1<<endl;
        else if((count[2]==1&&count[4]==1)||(count[3]==2)||(count[1]==2&&count[4]==1)) cout<<2<<endl;
        else if(count[2]==3) cout<<4<<endl;
        else if(count[1]==1&&count[2]==1&&count[3]==1) cout<<3<<endl;
        else if(count[1]==3&&count[3]==1) cout<<5<<endl;
        else if(count[1]==2&&count[2]==2) cout<<8<<endl;
        else if(count[1]==4) cout<<15<<endl;
        else if(count[1]==6) cout<<30<<endl;
        str.clear();
    }
    return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
struct node
{
    char x;
    int y;

}node1[10];

int cmp(node a,node b)
{
    return a.y<b.y;
}
int main()
{
    int k=0;
    char a[6];
    while(cin>>a)
    {
        k=1;
        for(int i=0;i<6;i++)
        {
            node1[i].x=' ';
            node1[i].y=0;

        }
        node1[0].x=a[0];
        node1[0].y=1;
        for(int i=1;i<6;i++)
        {
            int mark=0;
            for(int j=0;j<k;j++)
            {
                if(node1[j].x==a[i])
                {
                    node1[j].y++;
                    mark=1;
                    break;
                }
            }
            if(mark==0)
            {
                node1[k].x=a[i];
                node1[k].y++;
                k++;
            }
        }
        if(k==1)  cout<<"1"<<endl;
        else
        {
            sort(node1,node1+k,cmp);
            if(k==2)
            {
                if(node1[0].y==1&&node1[1].y==5)  cout<<"1"<<endl;
                else if(node1[0].y==2&&node1[1].y==4) cout<<"2"<<endl;
                else if(node1[0].y==3&&node1[1].y==3)  cout<<"2"<<endl;
            }
            else if(k==3)
            {
                if(node1[0].y==1&&node1[1].y==1&&node1[2].y==4)  cout<<"2"<<endl;
                else cout<<"3"<<endl;
            }
            else if(k==4)
            {
                if(node1[0].y==1&&node1[1].y==1&&node1[2].y==1&&node1[3].y==3)  cout<<"5"<<endl;
                else cout<<"8"<<endl;
            }
            else if(k==6)  cout<<"30"<<endl;
            else cout<<"24"<<endl;
        }
    }
    return 0;
}

#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<VI, bool> MVIB;

//   4
// 0 1 2 3
//   5

VVI Rotaciones;
MVIB Trobada;

void Rotar(VI& cubo) {
	//Rotacion 1
	VI rot1(6);
	rot1[0] = cubo[0];
	rot1[1] = cubo[4];
	rot1[2] = cubo[2];
	rot1[3] = cubo[5];
	rot1[4] = cubo[3];
	rot1[5] = cubo[1];
	if (not Trobada[rot1]) {
		Trobada[rot1] = true;
		Rotaciones.push_back(rot1);
		Rotar(rot1);
	}

	//Rotacion 1
	VI rot2(6);
	rot2[0] = cubo[3];
	rot2[1] = cubo[0];
	rot2[2] = cubo[1];
	rot2[3] = cubo[2];
	rot2[4] = cubo[4];
	rot2[5] = cubo[5];
	if (not Trobada[rot2]) {
		Trobada[rot2] = true;
		Rotaciones.push_back(rot2);
		Rotar(rot2);
	}
}

int main(){
	VI cubo(6);
	for (int i = 0; i < 6; ++i) cubo[i] = i;
	Rotaciones.push_back(cubo);
	Trobada[cubo] = true;
	Rotar(cubo);
	VI colores(6);
	for (int i = 0; i < 6; ++i) {
		char c; cin >> c;
		colores[i] = c - 'a';
	}

	int res = 0;
	Trobada.clear();
	do {
		bool trob = false;
		for (int i = 0; i < int(Rotaciones.size()); ++i) {
			VI rot(6);
			for (int j = 0; j < 6; ++j) rot[j] = colores[Rotaciones[i][j]];
			if (Trobada[rot]) trob = true;
		}
		if (not trob) {
			Trobada[colores] = true;
			++res;
		}
	} while (next_permutation(colores.begin(), colores.end()));

	//cout << int(Rotaciones.size()) << endl;
	//for (int i = 0; i < int(Rotaciones.size()); ++i) {
	//	for (int j = 0; j < 6; ++j) cout << Rotaciones[i][j] << " ";
	//	cout << endl;
	//	VI colores = color(Rotaciones[i]);
	//	for (int j = 0; j < int(colores.size()); ++j) cout << colores[j] << " ";
	//	cout << endl;
	//}

	cout << res << endl;
}

#include <bits/stdc++.h>
typedef long long li;
typedef unsigned long long uli;
#define inf  (int)(1e9)
#define inf2 (li)(LLONG_MAX-1)
#define pb push_back
#define F first
#define S second
#define R return
#define C continue
#define B break
#define MP make_pair
#define MOD (li)(1e9+7)
#define M_PI acos(-1)
using namespace std;
char s[10];
int ar[10];
int main(){

    scanf("%s",&s);
    for(int i=0;i<6;i++)
    {
            if(s[i]=='R')ar[0]++;
            if(s[i]=='O')ar[1]++;
            if(s[i]=='Y')ar[2]++;
            if(s[i]=='G')ar[3]++;
            if(s[i]=='B')ar[4]++;
            if(s[i]=='V')ar[5]++;
    }
    sort(ar,ar+6);
    if(ar[5]==6 ||ar[5]==5) cout << 1 << endl;
    else if(ar[5]==4) cout << 2 << endl;
    else if(ar[5]==3 && ar[4]==1) cout << 5 << endl;
    else if(ar[5]==3 && ar[4]==2) cout << 3 << endl;
    else if(ar[5]==3 && ar[4]==3) cout << 2 << endl;
    else if(ar[5]==2 && ar[4]==1) cout << 15 << endl;
    else if(ar[5]==2 && ar[4]==2) cout << 8 << endl;
    else if(ar[5]==2 && ar[4]==2 && ar[3]==2) cout << 6 << endl;
    else if(ar[5]==1) cout << 30 << endl;

    R 0;
}

#include <stdio.h>
#include <string>
#include <algorithm>

using namespace std;

//
//
//
//
//

char s[10];
string str[1000];
int vis[1000];

struct cube
{
	char v1, v2, v3, v4, v5, v6;

	cube (string str)
	{
		v1 = str[0];
		v2 = str[1];
		v3 = str[2];
		v4 = str[3];
		v5 = str[4];
		v6 = str[5];
	}

	bool same(cube t)
	{
		return v1 == t.v1 &&
			v2 == t.v2 &&
			v3 == t.v3 &&
			v4 == t.v4 &&
			v5 == t.v5 &&
			v6 == t.v6;
	}

	cube()
	{
	}

	cube left()
	{
		cube ret;

		ret.v1 = v2;
		ret.v2 = v3;
		ret.v3 = v4;
		ret.v4 = v1;
		ret.v5 = v5;
		ret.v6 = v6;
		return ret;
	}

	cube up()
	{
		cube ret;

		ret.v1 = v6;
		ret.v2 = v2;
		ret.v3 = v5;
		ret.v4 = v4;
		ret.v5 = v1;
		ret.v6 = v3;
		return ret;
	}
};

bool same(string a, string b)
{
	cube ca (a);
	cube cb (b);

	cube tc;

	tc = ca;

	//v5
	for (int i = 0; i < 4; i++)
	{
		if (tc.same(cb))	return true;
		tc = tc.left();
	}

	//v6
	tc.v5 = ca.v6;
	tc.v6 = ca.v5;

	tc.v1 = ca.v4;
	tc.v2 = ca.v3;
	tc.v3 = ca.v2;
	tc.v4 = ca.v1;

	for (int i = 0; i < 4; i++)
	{
		if (tc.same(cb))	return true;
		tc = tc.left();
	}

	//v1

	tc.v5 = ca.v1;
	tc.v6 = ca.v3;

	tc.v1 = ca.v6;
	tc.v2 = ca.v2;
	tc.v3 = ca.v5;
	tc.v4 = ca.v4;
	for (int i = 0; i < 4; i++)
	{
		if (tc.same(cb))	return true;
		tc = tc.left();
	}

	//v2

	tc.v5 = ca.v2;
	tc.v6 = ca.v4;

	tc.v1 = ca.v5;
	tc.v2 = ca.v1;
	tc.v3 = ca.v6;
	tc.v4 = ca.v3;
	for (int i = 0; i < 4; i++)
	{
		if (tc.same(cb))	return true;
		tc = tc.left();
	}

	//v3

	tc.v5 = ca.v3;
	tc.v6 = ca.v1;

	tc.v1 = ca.v5;
	tc.v2 = ca.v2;
	tc.v3 = ca.v6;
	tc.v4 = ca.v4;
	for (int i = 0; i < 4; i++)
	{
		if (tc.same(cb))	return true;
		tc = tc.left();
	}

	//v4

	tc.v5 = ca.v4;
	tc.v6 = ca.v2;

	tc.v1 = ca.v1;
	tc.v2 = ca.v5;
	tc.v3 = ca.v3;
	tc.v4 = ca.v6;
	for (int i = 0; i < 4; i++)
	{
		if (tc.same(cb))	return true;
		tc = tc.left();
	}

	return false;
}

int main()
{
	scanf("%s", s);

	sort(s, s + 6);

	s[6] = 0;

	int c = 0;

	do
	{
		vis[c] = 0;
		str[c++] = string(s);
	}
	while (next_permutation(s, s + 6));
	int ans = 0;

	printf("%d\n", c);

	for (int i = 0; i < c; i++)
	{
		if (vis[i])	continue;
		ans++;
		for (int j = 0; j < c; j++)
		{
			if (i == j || same(str[i], str[j]))
				vis[j] = 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define forn(i, x, n) for(int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for(int i = int(n); i >= int(x); --i)
#define file ""
#define pb push_back
#define S first
#define F second
#define _bits __builtin_popcountll

typedef long long ll;
typedef pair <ll, ll> PII;
typedef double ld;

const int N = 2e6;
const int INF = 1e9 + 9;
const int B = 1e9 + 7;

typedef vector <int> vi;

void rotate_left(vi &v) {
	int o = v[2];
	v[2] = v[4];
	v[4] = v[3];
	v[3] = v[1];
	v[1] = o;
}

void rotate_up(vi &v) {
	int o = v[5];
	v[5] = v[4];
	v[4] = v[0];
	v[0] = v[1];
	v[1] = o;
}

int main() {
#ifdef machine42
	freopen(file"in", "r", stdin);
	freopen(file"out", "w", stdout);
#endif
	ios_base :: sync_with_stdio (0);
	cin.tie(0);

	string s;
	cin >> s;
	vi v;
	map <vi, int> mp;
	for (auto c : s)
		v.pb(c - 'A');
	int ans = 0;
	do {
		vi t = v;
		if (mp[t]) continue;
		++ans;
		forn(k, 0, 3) {
			forn(i, 0, 3) {
				forn(j, 0, 3) {
					++mp[t];
					rotate_left(t);
				}
				rotate_up(t);
			}
			rotate_left(t);
		}
	} while (next_permutation(v.begin(), v.end()));

	cout << ans << "\n";

    return 0;
}

#include <bits/stdc++.h>
#define left kaira
using namespace std;
string st;
int sz = 0;

set<string>visited;
vector<char> left;
string curr="";

void comp(){
    if(!left.size()){
        if(visited.find(curr) != visited.end())return;
        swap(curr[0],curr[1]);
        if(visited.find(curr) != visited.end())return;
        swap(curr[0],curr[1]);

        swap(curr[2],curr[3]);
        if(visited.find(curr) != visited.end())return;
        swap(curr[2],curr[3]);

        swap(curr[4],curr[5]);
        if(visited.find(curr) != visited.end())return;
        swap(curr[4],curr[5]);
        cout << curr << endl;
        sz++;
        return;
    }

    for(int i = 0; i < left.size(); i++){
        char del = left[i];
        left.erase(left.begin()+i);
        curr+=(del);
        comp();
        curr.pop_back();
        left.insert(left.begin()+i,del);
    }

}

int main(){
    cin >> st;
    for(int i = 0; i < st.length(); i++) left.push_back(st[i]);
    comp();
    cout << sz;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

set <string> perms;

string make_string(string x, int i, int j, int k, int l, int m, int n)
{
	return string(1, x[i - 1]) + string(1, x[j - 1]) + string(1, x[k - 1]) + string(1, x[l - 1]) + string(1, x[m - 1]) + string(1, x[n - 1]);
}

set <string> make_rotations(string x)
{
	set <string> ans;
	ans.insert(make_string(x, 1, 2, 3, 4, 5, 6));
	ans.insert(make_string(x, 6, 2, 5, 4, 1, 3));
	ans.insert(make_string(x, 3, 2, 1, 4, 6, 5));
	ans.insert(make_string(x, 5, 2, 6, 4, 3, 1));
	ans.insert(make_string(x, 1, 4, 3, 2, 5, 6));
	ans.insert(make_string(x, 6, 4, 5, 2, 1, 3));
	ans.insert(make_string(x, 3, 4, 1, 2, 6, 5));
	ans.insert(make_string(x, 5, 4, 6, 2, 3, 1));

	ans.insert(make_string(x, 4, 3, 2, 1, 5, 6));
	ans.insert(make_string(x, 6, 3, 5, 1, 4, 2));
	ans.insert(make_string(x, 2, 3, 4, 1, 6, 5));
	ans.insert(make_string(x, 5, 3, 6, 1, 2, 4));
	ans.insert(make_string(x, 4, 1, 2, 3, 5, 6));
	ans.insert(make_string(x, 6, 1, 5, 3, 4, 2));
	ans.insert(make_string(x, 2, 1, 4, 3, 6, 5));
	ans.insert(make_string(x, 5, 1, 6, 3, 2, 4));

	ans.insert(make_string(x, 1, 6, 3, 5, 2, 4));
	ans.insert(make_string(x, 4, 6, 2, 5, 1, 3));
	ans.insert(make_string(x, 3, 6, 1, 5, 4, 2));
	ans.insert(make_string(x, 2, 6, 4, 5, 3, 1));
	ans.insert(make_string(x, 1, 5, 3, 6, 2, 4));
	ans.insert(make_string(x, 4, 5, 2, 6, 1, 3));
	ans.insert(make_string(x, 3, 5, 1, 6, 4, 2));
	ans.insert(make_string(x, 2, 5, 4, 6, 3, 1));

	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	string x;
	cin>>x;
	do
	{
		perms.insert(x);
	} while (next_permutation(x.begin(), x.end()));

	for (auto p: perms)
	{
		for (auto rot: make_rotations(p))
			if (p != rot && perms.find(rot) != perms.end())
				perms.erase(rot);
	}
	cout<<perms.size()<<endl;
	return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int kod(vector<int> x){
    sort(x.begin(), x.begin()+6);
    return x[0]*100000 + x[1]*10000 + x[2]*1000 + x[3]*100 + x[4]*10 + x[5]*1;

}

int main(){
    vector<int> x;
    x.resize(6);
    for(int i = 0; i<6; i++) x[i] = 0;
    char znak;
    for(int i=0; i<6; i++){
        cin >> znak;
        if(znak == 'R')x[0]++;
        if(znak == 'O')x[1]++;
        if(znak == 'Y')x[2]++;
        if(znak == 'G')x[3]++;
        if(znak == 'B')x[4]++;
        if(znak == 'V')x[5]++;
    }
    int wynik;
    wynik = kod(x);
    if(wynik == 6) cout <<1;
    if(wynik == 15) cout <<1;
    if(wynik == 24) cout <<2;
    if(wynik == 114) cout <<2;
    if(wynik == 33) cout <<2;
    if(wynik == 123) cout <<4;
    if(wynik == 1113) cout <<5;
    if(wynik == 222) cout <<6;
    if(wynik == 1122) cout <<8;
    if(wynik == 11112) cout <<15;
    if(wynik == 111111) cout <<30;
    return 0;
}

#include <bits/stdc++.h>

#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(ll i=n;i<=N;++i)
#define rap(i,n,N) for(ll i=n;i>=N;--i)
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define plll pair<ll,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl "\n"
const int MAX = 1e3+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll INF = 1e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 450;

int ans;
string s,t;
set<string> st;

int main(){
//	cout<<fixed<<setprecision(15);
//    freopen("class_treasurer.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>s;
    sort(all(s));
    do {
    	t = s;
    	if(!st.count(t)){
    		++ans;
//    		cout<<t<<endl;
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);

			swap(t[0],t[1]), swap(t[5],t[3]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);

			swap(t[0],t[2]), swap(t[5],t[4]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);

			swap(t[2],t[4]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);

			swap(t[0],t[1]), swap(t[5],t[3]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);

			swap(t[0],t[2]), swap(t[5],t[4]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
		}
	}while(next_permutation(all(s)));
	cout<<ans<<endl;
	return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int kod(vector<int> x){
    sort(x.begin(), x.begin()+6);
    return x[0]*100000 + x[1]*10000 + x[2]*1000 + x[3]*100 + x[4]*10 + x[5]*1;

}

int main(){
    vector<int> x;
    x.resize(6);
    for(int i = 0; i<6; i++) x[i] = 0;
    char znak;
    for(int i=0; i<6; i++){
        cin >> znak;
        if(znak == 'R')x[0]++;
        if(znak == 'O')x[1]++;
        if(znak == 'Y')x[2]++;
        if(znak == 'G')x[3]++;
        if(znak == 'B')x[4]++;
        if(znak == 'V')x[5]++;
    }
    int wynik;
    wynik = kod(x);
    if(wynik == 6) cout <<1;
    if(wynik == 15) cout <<1;
    if(wynik == 24) cout <<2;
    if(wynik == 114) cout <<2;
    if(wynik == 33) cout <<2;
    if(wynik == 123) cout <<4;
    if(wynik == 1113) cout <<8;
    if(wynik == 222) cout <<6;
    if(wynik == 1122) cout <<12;
    if(wynik == 11112) cout <<6;
    if(wynik == 111111) cout <<30;
    return 0;
}

// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

int kk[7];

int main() {
	string s; cin >> s;
	int n = s.length();
	sort(s.begin(), s.end());
	for (int i = 0, j; i < n; i = j) {
		j = i + 1;
		while (j < n && s[j] == s[i])
			j++;
		kk[j - i]++;
	}
	int ans;
	if (kk[6] == 1 || kk[5] == 1 && kk[1] == 1)
		ans = 1;
	else if (kk[4] == 1 || kk[3] == 2)
		ans = 2;
	else if (kk[3] == 1 && kk[2] == 1 && kk[1] == 1)
		ans = 3;
	else if (kk[3] == 1 && kk[1] == 3)
		ans = 5;
	else if (kk[2] == 3)
		ans = 2;
	else if (kk[2] == 2 && kk[1] == 2)
		ans = 8;
	else if (kk[2] == 1 && kk[1] == 4)
		ans = 15;
	else
		ans = 30;
	cout << ans << '\n';
	return 0;
}

#include <map>
#include <algorithm>
#include <iostream>
using namespace std;

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair

int main(int argc, char *argv[]) {
  string s;
  getline(cin,s);
  map<char,int> m;
  int ar[] = {0,30,6,5,2,1,1}, res = 0;

  rep(i,6) {
    if(m.count(s[i])) m[s[i]]++;
    else m.insert(mp(s[i],1));

    if (res < m[s[i]]) {
      res = m[s[i]];
    }
  }

  if (res == 3 && m.size() == 2) {
    cout<<2<<endl; return 0;
  }

  if (res == 3 && m.size() == 3) {
    cout<<3<<endl; return 0;
  }

  cout<<ar[res]<<endl;
  return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s;
int mas[6];
int main()
{
cin>>s;
for(int i=0; i<s.length();i++)
{
	if(s[i]=='R'){mas[0]++;}
	if(s[i]=='O'){mas[1]++;}
	if(s[i]=='Y'){mas[2]++;}
	if(s[i]=='G'){mas[3]++;}
	if(s[i]=='B'){mas[4]++;}
	if(s[i]=='V'){mas[5]++;}
}
sort(mas,mas+6);
//for(int i=0;i<6;i++){cout<<mas[i];}

if(mas[5]==6){cout<<1; return 0;}

if(mas[5]==5){cout<<1; return 0;}

if(mas[5]==4){cout<<2; return 0;}

if(mas[5]==3&&mas[4]==3){cout<<2; return 0;}
if(mas[5]==3&&mas[4]==1){cout<<6; return 0;}
if(mas[5]==3&&mas[4]==2){cout<<4; return 0;}

if(mas[5]==2){cout<<6; return 0;}

if(mas[5]==1){cout<<30; return 0;}

cin>>s;
return 0;
}

#include <bits/stdc++.h>
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}

void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//<key,mapped type,comparator,...>
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

int RL[6] = {0,2,3,4,1,5};
int  T[6][6]    = {
				  {0,1,2,3,4,5},
/*int T1[] =*/    {1,5,2,0,4,3},
/*int T2[] =*/    {2,1,5,3,0,4},
/*int T3[] =*/    {3,0,2,5,4,1},
/*int T4[] =*/    {4,1,0,3,5,2},
/*int T5[] =*/    {5,3,2,1,4,0}
				  };

vector<string> v;

vector<string> hacer_transformacion(string s){

	int l = s.size();
	string aux = s,aux1 = s;
	vector<string> r;

	FOR(i,6){
		FOR(j,6) aux[T[i][j]] = s[j];
		r.pb(aux);
		FOR(k,3){
			FOR(j,6) aux1[RL[j]] = aux[j];
			aux = aux1;
			r.pb(aux);
		}
	}

	return r;
}

bool esta(string s){
	vector<string> temp = hacer_transformacion(s);

	for(auto s1:temp)
		for(auto s2:v)
			if(s1==s2) return true;

	return false;
}

int main()
{
	string s;
	int cant = 0;
	cin>>s;
	v.pb(s);

	while(next_permutation(ALL(s)))
		if(!esta(s))
			v.pb(s);

	cout<<v.size()<<endl;

	return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
#include<stdio.h>
#include<memory.h>

//R O Y G B V
//1 2 3 4 5 6
//nCm=n!/((n-m)!*m!)

int CCC(int n,int m)
{
    int i;
    int np=1,mp=1,nmp=1;
    for(i=1;i<=n;i++)
        np*=i;
    for(i=1;i<=(n-m);i++)
        nmp*=i;
    for(i=1;i<=m;i++)
        mp*=i;
    return (np/(nmp*mp));
}
int Judge1(int t[])
{//6
    return 1;
}
int Judge2(int t[])
{
    if(t[1]==1&&t[2]==5)//1 5
        return 1;
    if(t[1]==2&&t[2]==4)//2 4
        return 2;
    if(t[1]==3&&t[2]==3)//3 3
        return 2;
}
int Judge3(int t[])
{
    if(t[1]==1)
    {
        if(t[2]==1)//1 1 4
            return 2;
        if(t[2]==2)//1 2 3
            return 2;
    }
    if(t[1]==2)//2 2 2
        return 4;
}
int Judge4(int t[])
{
    if(t[3]==1)//1 1 1 3
        return 5;
    if(t[3]==2)//1 1 2 2
        return 8;
}
int Judge5(int t[])
{//1 1 1 1 2
    return 15;
}
int Judge6(int t[])
{//1 1 1 1 1 1
    return 30;
}
int Judge(int n[])
{
    int temp[7],number;
    int i;
    for(i=1,number=0;i<=6;i++)
        if(n[i]!=0)
        {number++;temp[number]=n[i];}
    sort(&temp[1],&temp[1]+number);
    switch(number)
    {
        case 1:
            return Judge1(temp);
            break;
        case 2:
            return Judge2(temp);
            break;
        case 3:
            return Judge3(temp);
            break;
        case 4:
            return Judge4(temp);
            break;
        case 5:
            return Judge5(temp);
            break;
        case 6:
            return Judge6(temp);
            break;
        default:
            break;
    }
}
int main()
{
    int num[7];
    memset(num,0,sizeof(num));
    int i,ans;
    char ch;
    for(i=1;i<=6;i++)
    {
        scanf("%c",&ch);
        if(ch=='R')
        {num[1]++;}
        if(ch=='O')
        {num[2]++;}
        if(ch=='Y')
        {num[3]++;}
        if(ch=='G')
        {num[4]++;}
        if(ch=='B')
        {num[5]++;}
        if(ch=='V')
        {num[6]++;}
    }
    getchar();
    ans=Judge(num);
    printf("%d\n",ans);
    getchar();
    return 0;
}

#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
using namespace std;

int tran[3][6]={{0,2,3,4,1,5},
				{1,5,2,0,4,3},
				{2,1,5,3,0,4}
				};

set<string> hash;
bool flag;

void Gao(int deg,string s)
{
	if(flag||deg==4)return;
	for(int i=0;i<3;i++)
	{
		string t=s;
		for(int j=0;j<6;j++)
			t[j]=s[tran[i][j]];
		if(hash.count(t)==1)
		{
			flag=true;
			return;
		}
		Gao(deg+1,t);
	}

}

int main()
{
	string inp;
	cin>>inp;
	sort(inp.begin(),inp.end());
	do
	{
		flag=false;
		Gao(0,inp);
		if(flag==false)
			hash.insert(inp);
	}while(next_permutation(inp.begin(),inp.end()));
	/*
	cout<<hash.size()<<endl;
	set<string>::iterator it=hash.begin();
	for(;it!=hash.end();it++)
		cout<<*it<<endl;
		*/
	return 0;
}

#include <stdio.h>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <algorithm>

#define FOR(A, B) for(A=0;A<B;A++)

using namespace std;

char* rotace_1(char curr[])
{
	char* res = (char*)malloc(sizeof(char)*6);
	res[0] = curr[4];
	res[1] = curr[1];
	res[2] = curr[5];
	res[3] = curr[3];
	res[4] = curr[2];
	res[5] = curr[0];
	return res;
}

char* rotace_2(char curr[])
{
	char* res = (char*)malloc(sizeof(char)*6);
	res[0] = curr[0];
	res[1] = curr[5];
	res[2] = curr[2];
	res[3] = curr[4];
	res[4] = curr[1];
	res[5] = curr[3];
	return res;
}

char* rotace_3(char curr[])
{
	char* res = (char*)malloc(sizeof(char)*6);
	res[0] = curr[3];
	res[1] = curr[0];
	res[2] = curr[1];
	res[3] = curr[2];
	res[4] = curr[4];
	res[5] = curr[5];
	return res;
}

set<string> s;

bool dfs(char in[], int depth)
{
	if(s.find(in) != s.end()) return false;
	if(depth >= 6) return true;
	else {
		bool ok = true;
		ok &= dfs(rotace_1(in), depth+1);
		ok &= dfs(rotace_2(in), depth+1);
		ok &= dfs(rotace_3(in), depth+1);
		return ok;
	}
}

int main()
{
	char str[6];
	scanf("%s", str);

	int perms[] = {1,2,3,4,5,6};
	do {
		char current[6];
		int i;
		FOR(i, 6) current[i] = str[perms[i]-1];
		if(dfs(current, 0)) {
			s.insert(current);
		}
	} while(next_permutation(perms, perms+6));
	int res = s.size();
	printf("%d", res);
	return 0;
}

#include<cstdio>
#include<set>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
#define forf(x) for(a[x]=0;a[x]<6;a[x]++)
map<char,int> A;
int main()
{
    A['R']=0,A['O']=1,A['Y']=2,A['G']=3,A['B']=4,A['V']=5;
    char s[100];int a[100];
    scanf("%s",s);
    for(int i=0;i<6;i++)
        if(s[i]=='G')a[i]++;
    sort(a,a+6),reverse(a,a+6);
    int S;
    if(a[0]>=5)S=1;else
    if(a[0]==4)S=2;else
    if(a[1]==3)S=2;else
    if(a[0]==3&&a[1]==2)S=3;else
    if(a[0]==3)S=5;else
    if(a[2]==2)S=6;else
    if(a[1]==2)S=8;else
    if(a[0]==2)S=15;else S=30;
    printf("%d\n",S);
    return 0;
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

char s[10];
char s1[7]="ROYGBV";
int main()
{
    int i,j,num[6];
    while(gets(s))
    {
        memset(num,0,sizeof(num));
        for(i=0;i<6;i++)
        {
            for(j=0;j<6;j++)
                if(s[i]==s1[j])
                    break;
            num[j]++;
        }
        sort(num,num+6);
        if(num[5]==6) printf("1\n");
        else if(num[5]==5&&num[4]==1)
            printf("1\n");
        else if(num[5]==4&&num[4]==2)
            printf("2\n");
        else if(num[5]==3&&num[4]==3)
            printf("2\n");
        else if(num[5]==4&&num[4]==1)
            printf("3\n");
        else if(num[5]==3&&num[4]==2)
            printf("4\n");
        else if(num[5]==2&&num[4]==2&&num[3]==2)
            printf("6\n");
        else if(num[5]==3)
            printf("12\n");
        else if(num[5]==2&&num[4]==2)
            printf("7\n");
        else if(num[5]==2)
            printf("18\n");
        else printf("30\n");
    }
    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

const double eps = 1e-9;
const double PI = acos(-1.);

typedef pair<int, int>  PII;
typedef vector<int>     VI;
typedef long long       Long;

#define STR(a)        (((stringstream&)((stringstream()<<(a)))).str())
#define FOR(i,a,b)    for (int i = (a); i < b; ++i)
#define FOREACH(it,c) for(typeof((c).begin()) it = (c).begin(); it! = (c).end(); it++)
#define ALL(a)        (a).begin(), (a).end()
#define PB(a)         push_back(a)
#define MP            make_pair
#define XX            first
#define YY            second
#define PRINT(a)      cout << #a << " = " << a << endl;

string rotate(string & a)
{
	char b[] = {a[0], a[4], a[1], a[2], a[3], a[5]};
	return string(b);
}

string turn(string & a)
{
	char b[] = {a[2], a[1], a[5], a[3], a[0], a[4]};
	return string(b);
}

int main()
{
	//freopen("data.txt", "r", stdin);

	const int n = 6;
	string color;
	cin >> color;
	sort(color.begin(), color.end());

	set<string> seen;
	string a;
	int ct = 0;

	do
	{
		a = color;
		bool found = false;

		for (int i=0; i<4; i++)
		{
			for (int j=0; j<4; j++)
			{
				if (seen.find(a) != seen.end())
				{
					found = true;
					goto skip;
				}

				a = rotate(a);
			}

			a = turn(a);
		}

		a = rotate(a);

		for (int i=0; i<4; i++)
		{
			for (int j=0; j<4; j++)
			{
				if (seen.find(a) != seen.end())
				{
					found = true;
					goto skip;
				}

				a = rotate(a);
			}

			a = turn(a);
		}

skip:
		if (!found)
		{
			ct++;
			seen.insert(a);
		}
	}
	while ( next_permutation(color.begin(), color.end()) );

	cout << ct << endl;
}

/*
 * Author: kymo
 * Created Time:  2011/7/22 23:33:25
 * File Name: 3.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string.h>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define F(a,b) for(int i = a;i <= b;i ++)
#define int_max 99999999999LL
#define eps 1.0e-6
#define max 100
string aa;
int visited[max];
char str[7] = {'R','O','Y','G','B','V'};
int c(int n,int m){
    if(m == 0) return 1;
    else return (n*c(n-1,m-1))/m;
}
int a[max];
int main() {
    cin>>aa;
    int  N = 0;
    for(int j = 0;j <= 5;j ++){
        visited[j] = 0;
        for(int l = 0;l <= aa.length()-1;l ++){
            if(str[j] == aa[l]){
                visited[j] ++;
            }
        }
    }
    int count = 1;
    for(int j = 0;j <= 5;j ++){
        if(visited[j]!=0) a[count ++] = visited[j];
    }
    count --;
    if(count == 1) cout<<1<<endl;
    else if(count == 6) cout<<30<<endl;
    else if(count == 5) cout<<15<<endl;
    else if(count == 4){
        int flag = 0;
        for(int j = 1;j <= count; j++){
            if(a[j] == 3) {
                flag = 1;
                break;
            }
        }
        if(!flag) cout<<8<<endl;
        else cout<<5<<endl;
    }
    else if(count == 3){
        int flag = 1;
        for(int j = 1;j <= count;j ++){
            if(a[j] == 4){
                flag = 0;
                break;
            }
            if(a[j] == 3){
                flag = 2;
                break;
            }
        }
        if(flag == 1) cout<<6<<endl;
        else if(flag == 2) cout<<3<<endl;
        else if(flag == 0) cout<<4<<endl;
        }
    else if(count == 2){
        int ff = 0;
        for(int j = 1;j <= count;j ++){
            if(a[j] == 3){
                cout<<2<<endl;
                break;
            }
            if(a[j] == 1){
                cout<<1<<endl;
                break;
            }
            if(a[j] == 2){
                cout<<2<<endl;
                break;
            }
        }
    }
    return 0;
}

#include<stdio.h>
#include<string.h>
int flag[6],total;
char l[100][7],list[7],str[7];
int  f2(int a,int b,int c,int d,int e,int f)
{
        int i;
        a--;
        b--;
        c--;
        d--;
        e--;
        f--;
        char cur[100];
        cur[6]='\0';
        cur[0]=list[a];
        cur[1]=list[b];
        cur[2]=list[c];
        cur[3]=list[d];
        cur[4]=list[e];
        cur[5]=list[f];
        for(i=0;i<total;i++)
        {
                if(strcmp(cur,l[i])==0)
                        return 1;
        }

        cur[2]=list[d];
        cur[3]=list[e];
        cur[4]=list[f];
        cur[5]=list[c];

        for(i=0;i<total;i++)
        {
                if(strcmp(cur,l[i])==0)
                        return 1;
        }
        cur[2]=list[e];
        cur[3]=list[f];
        cur[4]=list[c];
        cur[5]=list[d];

        for(i=0;i<total;i++)
        {
                if(strcmp(cur,l[i])==0)
                        return 1;
        }

        cur[2]=list[f];
        cur[3]=list[c];
        cur[4]=list[d];
        cur[5]=list[e];

        for(i=0;i<total;i++)
        {
                if(strcmp(cur,l[i])==0)
                        return 1;
        }
        return 0;
}
void f(int x)
{
        int yes;
        int i;
        if(x==6)
        {
                list[x]='\0';
                //printf("%s\n",list);
                //return;
                yes=0;
                yes+=f2(1,2,3,4,5,6);
                if(yes)
                        return;
                yes+=f2(2,1,5,4,3,6);

                if(yes)
                        return;
                yes+=f2(3,5,2,4,1,6);

                if(yes)
                        return;
                yes+=f2(5,3,1,4,2,6);
                if(yes)
                        return;
                yes+=f2(4,6,3,2,5,1);

                if(yes)
                        return;
                yes+=f2(6,4,5,1,3,2);
                if(yes==0)
                        strcpy(l[total++],list);
                return;
        }
        for(i=0;i<6;i++)
        {
                if(flag[i]==0)
                {
                        flag[i]=1;
                        list[x]=str[i];
                        f(x+1);
                        flag[i]=0;
                }

        }
}
int main()
{
        int i;
        while(scanf("%s",str)!=EOF)
        {
                total=0;
                for(i=0;i<6;i++)
                        flag[i]=0;
                f(0);
                printf("%d\n",total);
        }
        return 0;
}

#include <stdio.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <memory.h>
#include <vector>
#include <math.h>
#include <set>
using namespace std;

#define PI 3.141592653589793
#define INF 2123456789
#define NUL 0.0000001

#define SZ size()
#define CS c_str()
#define PB push_back
#define INS insert
#define EMP empty()
#define CLR clear()
#define LEN length()

int R[] = {0, 4, 1, 2, 3, 5, 6};
int F[] = {0, 5, 2, 6, 4, 3, 1};

char ch[10];
bool mark[10];
int a[10], tmp[10];

char com[100000][10];
int cnum = 0;

void pic(int a[], int f[], int t){
    int tmp[10];
    for (int i = 1; i <= t; i++){
        for (int j = 1; j <= 6; j++) tmp[j] = a[j];

        for (int j = 1; j <= 6; j++) a[j] = tmp[ f[j] ];
    }
}

void idar(int pos){
    if (pos == 7){
        //for (int i = 1; i <= 6; i++) printf("%d ", a[i]); printf("\n");
        bool ima = false;
        for (int i = 0; i <= 3; i++)
            for (int j = 0; j <= 3; j++){
                for (int k = 1; k <= 6; k++) tmp[k] = a[k];

                pic(tmp, R, i); pic(tmp, F, j);

                for (int k = 1; k <= cnum; k++){
                    bool eq = true;
                    for (int l = 1; l <= 6; l++)
                        if (com[k][l] != ch[ tmp[l] ]) eq = false;

                    if (eq) ima = true;
                }
            }

        if (!ima){
            cnum++;
            for (int i = 1; i <= 6; i++) com[cnum][i] = ch[ a[i] ];
        }
        return;
    }
    for (int i = 1; i <= 6; i++) if (!mark[i]){
        a[pos] = i; mark[i] = true;
        idar(pos + 1);
        mark[i] = false;
    }
}

int main(){
    scanf("%s", ch+1);

    memset(mark, false, sizeof(mark));
    idar(1);

    printf("%d\n", (cnum + 1) / 2);
    return 0;
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

char s[10];
char s1[7]="ROYGBV";
int main()
{
    int i,j,num[6];
    while(gets(s))
    {
        memset(num,0,sizeof(num));
        for(i=0;i<6;i++)
        {
            for(j=0;j<6;j++)
                if(s[i]==s1[j])
                    break;
            num[j]++;
        }
        sort(num,num+6);
        if(num[5]==6) printf("1\n");
        else if(num[5]==5)
            printf("1\n");
        else if(num[5]==4&&num[4]==2)
            printf("2\n");
        else if(num[5]==3&&num[4]==3)
            printf("2\n");
        else if(num[5]==4)
            printf("2\n");
        else if(num[5]==3&&num[4]==2)
            printf("4\n");
        else if(num[5]==2&&num[4]==2&&num[3]==2)
            printf("6\n");
        else if(num[5]==3)
            printf("12\n");
        else if(num[5]==2&&num[4]==2)
            printf("7\n");
        else if(num[5]==2)
            printf("18\n");
        else printf("30\n");
    }
    return 0;
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define pb push_back
#define mp make_pair
#define tr(s,i) for(vector<int>::iterator i=s.begin();i!=s.end();++i)
typedef vector<int> vi;
typedef vector<int>::iterator vit;
typedef map<string, int> msi;
typedef priority_queue<int> maxh;
typedef priority_queue<int, vector<int>, greater<int> > minh;

int a[9]; // BGORVY

int A(int n) {
    int s = 1;
    for (int i = 1; i <= n; s *= i++);
    return s;
}

int main() {
    int i, n, t;
    string s;
    cin >> s;
    for (i = 0; i < 6; i++) {
        char c = s[i];
        switch (c + 32) {
            case 'b': a[1]++; break;
            case 'g': a[2]++; break;
            case 'o': a[3]++; break;
            case 'r': a[4]++; break;
            case 'v': a[5]++; break;
            case 'y': a[6]++; break;
        }
    }
    sort(a, a + 9, greater<int>());
    if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1 && a[4] == 1 && a[5] == 1) {
        cout << 30 << endl;
    } else if (a[0] == 2 && a[1] == 1 && a[2] == 1 && a[3] == 1 && a[4] == 1 && a[5] == 0) {
        cout << 3+6*2 << endl;
    } else if (a[0] == 2 && a[1] == 2 && a[2] == 1 && a[3] == 1 && a[4] == 0 && a[5] == 0) {
        cout << 1+1*2+4 << endl;
    } else if (a[0] == 2 && a[1] == 2 && a[2] == 2 && a[3] == 0 && a[4] == 0 && a[5] == 0) {
        cout << 1 + 3*1 + 2 << endl;
    } else if (a[0] == 3 && a[1] == 1 && a[2] == 1 && a[3] == 1 && a[4] == 0 && a[5] == 0) {
        cout << 3 + 2 << endl;
    } else if (a[0] == 3 && a[1] == 2 && a[2] == 1 && a[3] == 0 && a[4] == 0 && a[5] == 0) {
        cout << 3 << endl;
    } else if (a[0] == 4 && a[1] == 1 && a[2] == 1) {
        cout << 2 << endl;
    } else if (a[0] == 4 && a[1] == 2) {
        cout << 2 << endl;
    } else if (a[0] == 5 && a[1] == 1) {
        cout << 1 << endl;
    } else if (a[0] == 3 && a[1] == 3) {
        cout << 2 << endl;
    } else if (a[0] == 6) {
        cout << 1 << endl;
    }
    return 0;
}

#include<iostream>
#define pb push_back
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef pair<int,int> P;
int main(){
    set<char> st;
    string s;

    cin>>s;
    int m=0;
    map<char,int> mp;
    for(int i=0;i<6;i++){
        mp[s[i]]++;
        m=max(m,mp[s[i]]);
        st.insert(s[i]);
    }
    int n=st.size();
    if(n==1){
        cout<<1<<endl;
    }else if(n==6){
        cout<<30<<endl;
    }else if(n==5){
        cout<<15<<endl;
    }else if(n==2){
        if(m==5)
            cout<<1<<endl;
        else
            cout<<2<<endl;
    }else if(n==3){
        cout<<2<<endl;
    }else{
        cout<<8<<endl;
    }

    return 0;
}

#define _CRT_SECURE_NO_DEPRECATE
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
#include <stack>
#include <cstring>
#include <ctime>
#include <cstdio>
#include <memory>
using namespace std;
#define pb push_back
#define INF 1000000000
#define L(s) (int)((s).end()-(s).begin())
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define rep(i,n) FOR(i,1,(n))
#define rept(i,n) FOR(i,0,(n)-1)
#define C(a) memset((a),0,sizeof(a))
#define ll long long
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define VI vector<int>
#define ppb pop_back
#define mp make_pair
#define pii pair<int,int>
#define pdd pair<double,double>
//#define x first
//#define y second
#define sqr(a) (a)*(a)
#define D(a,b) sqrt(((a).x-(b).x)*((a).x-(b).x)+((a).y-(b).y)*((a).y-(b).y))
#define pi 3.1415926535897932384626433832795028841971
//#define tt (ll+rr)/2
#define UN(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define rnd() ((rand() << 16) ^ rand())

string turnRight(string s)
{
	string p = "";
	p += s.substr(0, 4);
	rotate(p.begin(), p.begin() + 1, p.end());
	rept(i, 4)
		s[i] = p[i];

	return s;
}

string turnDown(string s)
{
	string p = "";
	p += s[1];
	p += s[3];
	p += s[4];
	p += s[5];

	rotate(p.begin(), p.begin() + 1, p.end());

	s[1] = p[0];
	s[3] = p[1];
	s[4] = p[2];
	s[5] = p[3];

	return s;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","rt",stdin); freopen("output.txt","wt",stdout);
    #endif

	string s;
	cin >> s;
	SORT(s);
	int res = 0;
	set<string> used;
	do
	{
		if (used.find(s) == used.end())
			res++;
		rept(i, 4)
			rept(j, 4)
			{
				string temp = s;
				rept(ci, i)
					temp = turnRight(temp);
				rept(ci, j)
					temp = turnDown(temp);
				used.insert(temp);
			}
	}
	while (next_permutation(all(s)));

	cout << res << endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
const int LEN = 100000;

struct fastio {
  int it, len;
  char s[LEN + 5];
  fastio() {
    it = len = 0;
  }
  char get() {
    if (it < len) return s[it++];
    it = 0, len = fread(s, 1, LEN, stdin);
    return len ? s[it++] : EOF;
  }
  bool notend() {
    char c;
    for (c = get(); c == ' ' || c == '\n' || c == '\r'; c = get());
    if (it) it--;
    return c != EOF;
  }
  void put(char c) {
    if (it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush() {
    fwrite(s, 1, it, stdout);
  }
}buff, bufo;
inline int getint() {
  char c; int res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if(c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll() {
  char c; ll res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if (c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char() {
  char c;
  for (c = buff.get(); c == ' ' || c == '\n' || c == '\r'; c = buff.get());
  return c;
}

set<string> S;

void dfs(string s) {
	if (S.find(s) != S.end()) return;
	S.insert(s);
	char s1[] = {s[1], s[2], s[3], s[0], s[4], s[5]};
	dfs(s1);
	char s2[] = {s[0], s[4], s[2], s[5], s[3], s[1]};
	dfs(s2);
}

string s;

int main() {
	int ans = 0;
	cin >> s;
	sort(s.begin(), s.end());
	do {
		if (S.find(s) != S.end()) continue;
		ans++;
		dfs(s);
	} while (next_permutation(s.begin(), s.end()));
	cout << ans << endl;
	return 0;
}

//sobskdrbhvk
#include <bits/stdc++.h>

using namespace std;

typedef long long int LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

#define PB push_back
#define MP make_pair
#define L first
#define R second
#define sz(x) ((int)(x).size())
#define smax(x, y) ((x) = max((x), (y)))
#define smin(x, y) ((x) = min((x), (y)))
#define all(x) x.begin(),x.end()

int cnt[26];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	for(auto c : s)
		cnt[c - 'A']++;
	sort(cnt, cnt + 26, greater<int>());
	if(cnt[0] == 1)
		cout << 30 << endl;
	else if(cnt[0] == 2){
		if(cnt[1] == 2){
			if(cnt[2] == 2)
				cout << 6 + 2 << endl;
			else
				cout << 8 << endl;
		}
		else
			cout << 15 << endl;
	}
	else if(cnt[0] == 3){
		if(cnt[1] == 3)
			cout << 1 + 1 << endl;
		else if(cnt[1] == 2)
			cout << 1 + 2 << endl;
		else
			cout << 2 + 3 << endl;
	}
	else if(cnt[0] == 4)
		cout << 2 << endl;
	else
		cout << 1 << endl;
	return 0;
}

#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;
int f[7];
char a[7];

int ans(int x){
    if (x == 7) return 1;
    if (x == 12) return 1;
    if (x == 15) return 2;
    if (x == 9) return 2;
    if (x == 20) return 2;
    if (x == 24) return 3;
    if (x == 27) return 6;
    if (x == 32) return 5;
    if (x == 36) return 8;
    if (x == 48) return 15;
    if (x == 64) return 30;
    }

int main(){
    gets(a + 1);
    sort(a + 1, a + 7);
    int l = 1;
    for (int i = 1; i <= 6; i++) f[i] = 1;
    f[1] ++;
    for (int i = 2; i <= 6; i++)
        if (a[i] == a[i - 1]) f[l] ++;
        else f[++l] ++;
    int x = f[1] * f[2] * f[3] * f[4] * f[5] * f[6];
    printf("%d", ans(x));
    return 0;
}

#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;
int f[7];
char a[7];

int ans(int x){
    if (x == 7) return 1;
    if (x == 12) return 1;
    if (x == 15) return 2;
    if (x == 16) return 2;
    if (x == 20) return 2;
    if (x == 24) return 3;
    if (x == 27) return 5;
    if (x == 32) return 5;
    if (x == 36) return 8;
    if (x == 48) return 15;
    if (x == 64) return 30;
    }

int main(){
    gets(a + 1);
    sort(a + 1, a + 7);
    int l = 1;
    for (int i = 1; i <= 6; i++) f[i] = 1;
    f[1] ++;
    for (int i = 2; i <= 6; i++)
        if (a[i] == a[i - 1]) f[l] ++;
        else f[++l] ++;
    //scout << f[1] << f[2] << f[3] << endl;
    int x = f[1] * f[2] * f[3] * f[4] * f[5] * f[6];
    printf("%d", ans(x));
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
//#define f first
//#define s second
const int N = 3e5 + 5;
const double pi = acos(-1);
const int mod = 1e9 + 7;

ll fastpow(ll b, ll e) {
    if (!e) return 1;
    ll ret = fastpow(b, e / 2);
    ret = (ret * ret) % mod;
    if (e % 2) ret = (ret * b) % mod;
    return ret;
}
ll mi(int x) {
    return fastpow(x, mod - 2);
}
int main()
{
    map<char, int> sc;
    string s;
    cin >> s;
    for (int i = 0; i < 6; i++)
        sc[s[i]]++;
    int num = sc.size();
    if (num == 1 || (num == 2 && (sc.begin()->second == 1 || sc.rbegin()->second == 1))) {
        cout << 1;
    }
    else {
        int n = 1, k = 1;
        for (int i = num; i > num - 2; i--) {
            n *= i;
            n /= k;
            k++;
        }
        cout << 2 * n << '\n';
    }
    return 0;
}

#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

const int INF = 2000000000;

typedef long double ld;

const int f[3][8] = {{0,1,3,5,0,1,3,5},{0,2,3,4,0,2,3,4},{2,1,4,5,2,1,4,5}};

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int ans = 0;
    string a;
    cin >> a;

    set<string> d;
    do
    {
        if (d.count(a) > 0) continue;
        ans++;
        for (int i = 0; i < 3; i++)
        for (int ii = 0; ii < 3; ii++)
        for (int j = 0; j < 4; j++)
        for (int jj = 0; jj < 4; jj++)

            {
                string n0 = a;
                for (int k = 0; k < 4; k++)
                    n0[f[i][k]] = a[f[i][k+j]];
                string n = n0;
                for (int k = 0; k < 4; k++)
                    n[f[ii][k]] = n0[f[ii][k+jj]];
                d.insert(n);
            }

    } while(next_permutation(a.begin(),a.end()));

    cout << ans;

}

//Friday, July  22, 2011 09:32 CDT
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

int solve(vector<int> a) {
	if (a[0] == 6 || a[0] == 5)
		return 1;
	if (a[0] == 4)
		return 2;
	if (a[0] == 3) {
		if (a[1] == 3)
			return 2;
		if (a[1] == 2)
			return 3;
		if (a[1] == 1)
			return 5;
	}
	if (a[0] == 2) {
		if (a[1] == 2) {
			if (a[2] == 2)
				return 8;
			return 6;
		}
		return 15;
	}
	return 30;
}

int main(int argc, char* argv[]) {
	string s;
	cin >> s;
	vector<int> a(6, 0);
	for (int i = 0; i < 6; i++) {
		if (s[i] == 'R')
			a[0]++;
		if (s[i] == 'O')
			a[1]++;
		if (s[i] == 'Y')
			a[2]++;
		if (s[i] == 'G')
			a[3]++;
		if (s[i] == 'B')
			a[4]++;
		if (s[i] == 'V')
			a[5]++;
	}
	sort(a.rbegin(), a.rend());
	cout << solve(a) << endl;
	return 0;
}

#include <bits/stdc++.h>
typedef long long li;
typedef unsigned long long uli;
#define inf  (int)(1e9)
#define inf2 (li)(LLONG_MAX-1)
#define pb push_back
#define F first
#define S second
#define R return
#define C continue
#define B break
#define MP make_pair
#define MOD (li)(1e9+7)
#define M_PI acos(-1)
using namespace std;
set <string> x;
char s[6];
string cr(char a1,char a2,char a3,char a4,char a5,char a6)
{
    string ret="";
    ret+=a1;
    ret+=a2;
    ret+=a3;ret+=a4;ret+=a5;ret+=a6;
    R ret;
}
string mn(string st)
{
    string minn=st;
    string tst="";
    tst=cr(st[0],st[2],st[5],st[3],st[4],st[1]);
    minn=min(minn,tst);
    tst=cr(st[2],st[5],st[3],st[0],st[4],st[1]);
    minn=min(minn,tst);
    tst=cr(st[5],st[3],st[0],st[2],st[4],st[1]);
    minn=min(minn,tst);
    tst=cr(st[3],st[0],st[2],st[5],st[4],st[1]);
    minn=min(minn,tst);
    /**               */
    tst=cr(st[0],st[3],st[5],st[2],st[1],st[4]);
    minn=min(minn,tst);
    tst=cr(st[3],st[5],st[2],st[0],st[1],st[4]);
    minn=min(minn,tst);
    tst=cr(st[5],st[2],st[0],st[3],st[1],st[4]);
    minn=min(minn,tst);
    tst=cr(st[2],st[0],st[3],st[5],st[1],st[4]);
    minn=min(minn,tst);
    /**               */
    tst=cr(st[0],st[1],st[5],st[4],st[3],st[2]);
    minn=min(minn,tst);
    tst=cr(st[1],st[5],st[4],st[0],st[3],st[2]);
    minn=min(minn,tst);
    tst=cr(st[5],st[4],st[0],st[1],st[3],st[2]);
    minn=min(minn,tst);
    tst=cr(st[4],st[0],st[1],st[5],st[3],st[2]);
    minn=min(minn,tst);
    /**               */
    tst=cr(st[0],st[4],st[5],st[1],st[2],st[3]);
    minn=min(minn,tst);
    tst=cr(st[4],st[5],st[1],st[0],st[2],st[3]);
    minn=min(minn,tst);
    tst=cr(st[5],st[1],st[0],st[4],st[2],st[3]);
    minn=min(minn,tst);
    tst=cr(st[1],st[0],st[4],st[5],st[2],st[3]);
    minn=min(minn,tst);
    /**               */
    tst=cr(st[1],st[2],st[4],st[3],st[5],st[0]);
    minn=min(minn,tst);
    tst=cr(st[2],st[4],st[3],st[1],st[5],st[0]);
    minn=min(minn,tst);
    tst=cr(st[4],st[3],st[1],st[2],st[5],st[0]);
    minn=min(minn,tst);
    tst=cr(st[3],st[1],st[2],st[4],st[5],st[0]);
    minn=min(minn,tst);
    /**               */
    tst=cr(st[1],st[3],st[4],st[2],st[0],st[5]);
    minn=min(minn,tst);
    tst=cr(st[3],st[4],st[2],st[1],st[0],st[5]);
    minn=min(minn,tst);
    tst=cr(st[4],st[2],st[1],st[3],st[0],st[5]);
    minn=min(minn,tst);
    tst=cr(st[2],st[1],st[3],st[4],st[0],st[5]);
    minn=min(minn,tst);
    /**               */
    R minn;
}
int main(){

    scanf("%s",&s);
    do{
            x.insert(mn(s));

    }while(next_permutation(s,s+6));
    cout << x.size() << endl;

    R 0;
}

#include <stdio.h>
#include <map>
#include <string>
#include <algorithm>
#include <string.h>

using namespace std;

char cad[1000];
char aux[1000];
map<char, int> mapa;
map<string, int> mapa2;

int main()
{
    gets(cad);
    mapa2[string("6")] = 1;
    mapa2[string("15")] = 1;
    mapa2[string("24")] = 2;
    mapa2[string("33")] = 3;
    mapa2[string("114")] = 2;
    mapa2[string("123")] = 3;
    mapa2[string("222")] = 5;
    mapa2[string("1113")] = 5;
    mapa2[string("1122")] = 8;
    mapa2[string("11112")] = 15;
    mapa2[string("111111")] = 30;

    for (int i = 0; i < 6; i++)
    {
        mapa[cad[i]] = mapa[cad[i]] + 1;
    }

    int cont = 0;
    for (map<char, int>::iterator it = mapa.begin(); it != mapa.end(); it++)
    {
        aux[cont] = (*it).second + '0';
        cont++;
    }

    aux[cont] = 0;
    sort(aux, aux + strlen(aux));
    printf("%d", mapa2[string(aux)]);

}

#include <cstdio>

#include <algorithm>
#include <vector>
using namespace std;

const int kNumSides = 6;
const int kBufSize = 8;

const int side[6][5] = {
    { 5, 3, 2, 1, 4 },
    { 0, 2, 4, 5, 3 },
    { 0, 3, 4, 1, 5 },
    { 0, 5, 4, 2, 1 },
    { 2, 3, 5, 1, 0 },
    { 4, 3, 0, 1, 2 }
};

struct Cube {
  char front, back;
  char u, d, l, r;

  void Rotate(void) {
    char t = u;
    u = d;
    d = l;
    l = r;
    r = t;
  }

  bool IdenticallyEquals(const Cube &other) const {
    return front == other.front &&
      u == other.u &&
      d == other.d &&
      l == other.l &&
      r == other.r &&
      back == other.back;
  }
};

void MakeCube(int s, const char *sequence, Cube *cube) {
    cube->front = sequence[s];
    cube->u = sequence[side[s][0]];
    cube->r = sequence[side[s][1]];
    cube->d = sequence[side[s][2]];
    cube->l = sequence[side[s][3]];
    cube->back = sequence[side[s][4]];
}

bool IsTheSameCube(const Cube &cube, const char *sequence) {
  Cube ncube;
  for (int i = 0; i < kNumSides; ++i) {
    MakeCube(i, sequence, &ncube);

    for (int j = 0; j < 4; ++j) {
      if (cube.IdenticallyEquals(ncube))
	return true;
      ncube.Rotate();
    }
  }
  return false;
}

int main(void) {
  char sequence[kBufSize];
  scanf("%s", sequence);

  sort(sequence, sequence + kNumSides);
  vector<Cube> cubes;
  do {
    bool isNew = true;
    for (int i = 0; i < cubes.size() && isNew; ++i)
      if (IsTheSameCube(cubes[i], sequence))
	isNew = false;
    if (isNew) {
      Cube ncube;
      MakeCube(0, sequence, &ncube);
      cubes.push_back(ncube);
    }
  } while (next_permutation(sequence, sequence + kNumSides));
  printf("%d\n", (int) cubes.size());
  return 0;
}

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 100005;
int s[27];
char a[N];
int main() {
    scanf("%s", a);
    for(int i = 0; i < 6; i ++) {
        if(a[i] == 'R') s[0]++;
        else if(a[i] == 'O') s[1]++;
        else if(a[i] == 'Y') s[2]++;
        else if(a[i] == 'G') s[3]++;
        else if(a[i] == 'B') s[4]++;
        else if(a[i] == 'V') s[5]++;
    }
    sort(s, s+6);
    int sum = 0;
    for(int i = 0; i < 6; i ++) {
//      printf("%d ", s[i]);
        sum = sum * 10 + s[i];
    } //puts("");
//  printf("%d\n", sum);
    if(sum == 111111) puts("30");
    else if(sum == 11112) puts("2");
    else if(sum == 1113) puts("3");
    else if(sum == 1122) puts("4");
    else if(sum == 114) puts("2");
    else if(sum == 123) puts("3");
    else if(sum == 15) puts("1");
    else if(sum == 222) puts("3");
    else if(sum == 24) puts("2");
    else if(sum == 33) puts("2");
    else if(sum == 6) puts("1");

    return 0;
}

#include <bits/stdc++.h>

#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(ll i=n;i<=N;++i)
#define rap(i,n,N) for(ll i=n;i>=N;--i)
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define plll pair<ll,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl "\n"
const int MAX = 1e3+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll INF = 1e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 450;

int ans;
string s,t;
set<string> st;

int main(){
//	cout<<fixed<<setprecision(15);
//    freopen("class_treasurer.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>s;
    sort(all(s));
    do {
    	t = s;
    	if(!st.count(t)){
    		++ans;
//    		cout<<t<<endl;
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			reverse(t.begin()+1,t.begin()+5);
			swap(t[0],t[5]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
			reverse(t.begin()+1,t.begin()+5);

			swap(t[0],t[1]), swap(t[5],t[3]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			reverse(t.begin()+1,t.begin()+5);
			swap(t[0],t[5]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
			reverse(t.begin()+1,t.begin()+5);
			swap(t[0],t[1]), swap(t[5],t[3]);

			swap(t[0],t[2]), swap(t[5],t[4]);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
			reverse(t.begin()+1,t.begin()+5);
    		rep(i,1,4){
    			st.insert(t);
    			rep(j,1,3)swap(t[j],t[j+1]);
			}
			swap(t[0],t[5]);
			reverse(t.begin()+1,t.begin()+5);
		}
	}while(next_permutation(all(s)));
	cout<<ans<<endl;
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define V vector
#define MP make_pair
#define MAX INT_MAX
#define MIN INT_MIN
#define all(v)  ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(v, d) mmpet(v, d, sizeof(v))
#define sf(x) scanf("%d", &x)
#define sf2(x, y) scanf("%d %d", &x, &y)
#define sf3(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sfll(x) scanf("%I64d", &x)
#define sfll2(x, y) scanf("%I64d %I64d", &x, &y)
#define sfll3(x, y, z) scanf("%I64d %I64d %I64d", &x, &y, &z)
//ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
int dx[]{1, -1, 0, 0, 1, -1, 1, -1};
int dy[]{0, 0, 1, -1, 1, -1, -1, 1};
typedef unsigned long long          ull;
typedef long long                   ll;
typedef long double                 LD;
const int size = 1000006;
bool R[size], C[size];
int main()
{
	set<int>stt = { 1, 2, 3, 4, 6 };
	cout << stt.insert(5).second << endl;
	ll n, m, l;
	string s1;
	while (cin >> s1){
		sort(all(s1));
		map<string,bool>mp;
		int last = 0, ans = 0;
		do{
			string se = s1;
			mp[s1] = 1;
		} while (next_permutation(s1.begin(), s1.end()));

		bool done = 0;
		for (map<string , bool>::iterator it = mp.begin(); it != mp.end(); (done == 0 ? it++ : it)){
			string s = "!";
			s.append(it->first);
			done = 0;
			if (mp.find({ s[2], s[3], s[4], s[1], s[5], s[6] }) != mp.end() && mp.find({ s[2], s[3], s[4], s[1], s[5], s[6] })->first != s.substr(1)) { mp.erase(mp.find({ s[2], s[3], s[4], s[1], s[5], s[6] })),done = 1; };
			if (mp.find({ s[3], s[4], s[1], s[2], s[5], s[6] }) != mp.end() && mp.find({ s[3], s[4], s[1], s[2], s[5], s[6] })->first != s.substr(1)) { mp.erase(mp.find({ s[3], s[4], s[1], s[2], s[5], s[6] })),done = 1; };
			if (mp.find({ s[4], s[1], s[2], s[3], s[5], s[6] }) != mp.end() && mp.find({ s[4], s[1], s[2], s[3], s[5], s[6] })->first != s.substr(1)) { mp.erase(mp.find({ s[4], s[1], s[2], s[3], s[5], s[6] })),done = 1; };
			if (mp.find({ s[1], s[2], s[3], s[4], s[6], s[5] }) != mp.end() && mp.find({ s[1], s[2], s[3], s[4], s[6], s[5] })->first != s.substr(1)) { mp.erase(mp.find({ s[1], s[2], s[3], s[4], s[6], s[5] })),done = 1; };
			if (mp.find({ s[2], s[3], s[4], s[1], s[6], s[5] }) != mp.end() && mp.find({ s[2], s[3], s[4], s[1], s[6], s[5] })->first != s.substr(1)) { mp.erase(mp.find({ s[2], s[3], s[4], s[1], s[6], s[5] })),done = 1; };
			if (mp.find({ s[3], s[4], s[1], s[2], s[6], s[5] }) != mp.end() && mp.find({ s[3], s[4], s[1], s[2], s[6], s[5] })->first != s.substr(1)) { mp.erase(mp.find({ s[3], s[4], s[1], s[2], s[6], s[5] })),done = 1; };
			if (mp.find({ s[4], s[1], s[2], s[3], s[6], s[5] }) != mp.end() && mp.find({ s[4], s[1], s[2], s[3], s[6], s[5] })->first != s.substr(1)) { mp.erase(mp.find({ s[4], s[1], s[2], s[3], s[6], s[5] })),done = 1; };
			if (mp.find({ s[5], s[2], s[6], s[4], s[3], s[1] }) != mp.end() && mp.find({ s[5], s[2], s[6], s[4], s[3], s[1] })->first != s.substr(1)) { mp.erase(mp.find({ s[5], s[2], s[6], s[4], s[3], s[1] })),done = 1; };
			if (mp.find({ s[2], s[6], s[4], s[5], s[3], s[1] }) != mp.end() && mp.find({ s[2], s[6], s[4], s[5], s[3], s[1] })->first != s.substr(1)) { mp.erase(mp.find({ s[2], s[6], s[4], s[5], s[3], s[1] })),done = 1; };
			if (mp.find({ s[6], s[4], s[5], s[2], s[3], s[1] }) != mp.end() && mp.find({ s[6], s[4], s[5], s[2], s[3], s[1] })->first != s.substr(1)) { mp.erase(mp.find({ s[6], s[4], s[5], s[2], s[3], s[1] })),done = 1; };
			if (mp.find({ s[4], s[5], s[2], s[6], s[3], s[1] }) != mp.end() && mp.find({ s[4], s[5], s[2], s[6], s[3], s[1] })->first != s.substr(1)) { mp.erase(mp.find({ s[4], s[5], s[2], s[6], s[3], s[1] })),done = 1; };
			if (mp.find({ s[5], s[2], s[6], s[4], s[1], s[3] }) != mp.end() && mp.find({ s[5], s[2], s[6], s[4], s[1], s[3] })->first != s.substr(1)) { mp.erase(mp.find({ s[5], s[2], s[6], s[4], s[1], s[3] })),done = 1; };
			if (mp.find({ s[2], s[6], s[4], s[5], s[1], s[3] }) != mp.end() && mp.find({ s[2], s[6], s[4], s[5], s[1], s[3] })->first != s.substr(1)) { mp.erase(mp.find({ s[2], s[6], s[4], s[5], s[1], s[3] })),done = 1; };
			if (mp.find({ s[6], s[4], s[5], s[2], s[1], s[3] }) != mp.end() && mp.find({ s[6], s[4], s[5], s[2], s[1], s[3] })->first != s.substr(1)) { mp.erase(mp.find({ s[6], s[4], s[5], s[2], s[1], s[3] })),done = 1; };
			if (mp.find({ s[4], s[5], s[2], s[6], s[1], s[3] }) != mp.end() && mp.find({ s[4], s[5], s[2], s[6], s[1], s[3] })->first != s.substr(1)) { mp.erase(mp.find({ s[4], s[5], s[2], s[6], s[1], s[3] })),done = 1; };
			if (mp.find({ s[1], s[6], s[3], s[5], s[2], s[4] }) != mp.end() && mp.find({ s[1], s[6], s[3], s[5], s[2], s[4] })->first != s.substr(1)) { mp.erase(mp.find({ s[1], s[6], s[3], s[5], s[2], s[4] })),done = 1; };
			if (mp.find({ s[6], s[3], s[5], s[1], s[2], s[4] }) != mp.end() && mp.find({ s[6], s[3], s[5], s[1], s[2], s[4] })->first != s.substr(1)) { mp.erase(mp.find({ s[6], s[3], s[5], s[1], s[2], s[4] })),done = 1; };
			if (mp.find({ s[3], s[5], s[1], s[6], s[2], s[4] }) != mp.end() && mp.find({ s[3], s[5], s[1], s[6], s[2], s[4] })->first != s.substr(1)) { mp.erase(mp.find({ s[3], s[5], s[1], s[6], s[2], s[4] })),done = 1; };
			if (mp.find({ s[5], s[1], s[6], s[3], s[2], s[4] }) != mp.end() && mp.find({ s[5], s[1], s[6], s[3], s[2], s[4] })->first != s.substr(1)) { mp.erase(mp.find({ s[5], s[1], s[6], s[3], s[2], s[4] })),done = 1; };
			if (mp.find({ s[1], s[6], s[3], s[5], s[4], s[2] }) != mp.end() && mp.find({ s[1], s[6], s[3], s[5], s[4], s[2] })->first != s.substr(1)) { mp.erase(mp.find({ s[1], s[6], s[3], s[5], s[4], s[2] })),done = 1; };
			if (mp.find({ s[6], s[3], s[5], s[1], s[4], s[2] }) != mp.end() && mp.find({ s[6], s[3], s[5], s[1], s[4], s[2] })->first != s.substr(1)) { mp.erase(mp.find({ s[6], s[3], s[5], s[1], s[4], s[2] })),done = 1; };
			if (mp.find({ s[3], s[5], s[1], s[6], s[4], s[2] }) != mp.end() && mp.find({ s[3], s[5], s[1], s[6], s[4], s[2] })->first != s.substr(1)) { mp.erase(mp.find({ s[3], s[5], s[1], s[6], s[4], s[2] })),done = 1; };
			if (mp.find({ s[5], s[1], s[6], s[3], s[4], s[2] }) != mp.end() && mp.find({ s[5], s[1], s[6], s[3], s[4], s[2] })->first != s.substr(1)) { mp.erase(mp.find({ s[5], s[1], s[6], s[3], s[4], s[2] })),done = 1; };
			if(done) it = mp.begin();
		}
		cout << mp.size() << endl;
	}

	return 0;
}

#include <vector>
#include <string>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#include <functional>
#include <map>
using namespace std;

int main(){
    int i,a[6];
    vector<int> b;
    string str;
    cin>>str;
    for(i=0;i<6;i++){
        a[i]=0;
    }
    for(int i=0;i<str.size();i++){
        if(str[i]=='R'){
            a[0]+=1;
        }
        if(str[i]=='O'){
            a[1]+=1;
        }
        if(str[i]=='Y'){
            a[2]+=1;
        }
        if(str[i]=='G'){
            a[3]+=1;
        }
        if(str[i]=='B'){
            a[4]+=1;
        }
        if(str[i]=='V'){
            a[5]+=1;
        }
    }
    for(i=0;i<6;i++){
        b.push_back(a[i]);
    }
    sort(b.begin(),b.end());
    if(b[5]==6||b[5]==5){
        cout<<1<<endl;
    }else if(b[5]==4){
        cout<<2<<endl;
    }else if(b[5]==3&&b[4]==1){
        cout<<4<<endl;
    }else if(b[5]==3&&b[4]==2){
        cout<<3<<endl;
    }else if(b[5]==3&&b[4]==3){
        cout<<2<<endl;
    }else if(b[5]==2&&b[4]==2&&b[3]==2){
        cout<<6<<endl;
    }else if(b[5]==2&&b[4]==2&&b[3]==1){
        cout<<6<<endl;
    }else if(b[5]==2){
        cout<<18<<endl;
    }else if(b[5]==1){
        cout<<30<<endl;
    }

}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

char a[30];
int ans[10];
int ans2[10];

int main()
{
    int i;
    while(cin>>a)
    {
        memset(ans,0,sizeof(ans));
        memset(ans2,0,sizeof(ans2));
        for(i=0;i<6;i++)
        {
            switch (a[i])
            {
                case 'R':ans[0]++;break;
                case 'O':ans[1]++;break;
                case 'Y':ans[2]++;break;
                case 'G':ans[3]++;break;
                case 'B':ans[4]++;break;
                case 'V':ans[5]++;break;
            }
        }
        for(i=0;i<6;i++)
        {
            ans2[ans[i]]++;
        }
        if(ans2[6]==1)
        {
            printf("1\n");
            continue;
        }
        if(ans2[5]==1)
        {
            printf("1\n");
            continue;
        }
        if(ans2[4]==1)
        {
            printf("2\n");
            continue;
        }
        if(ans2[3]==2)
        {
            printf("2\n");
            continue;
        }
        if(ans2[3]==1)
        {
            if(ans2[2]==1)
                printf("3\n");
            else
                printf("9\n");
            continue;
        }
        if(ans2[2]==3)
        {
            printf("8\n");
            continue;
        }
        if(ans2[2]==2)
        {
            printf("8\n");
            continue;
        }
        if(ans2[2]==1)
        {
            printf("15\n");
            continue;
        }
        printf("30\n");
    }
    return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
struct node
{
    char x;
    int y;

}node1[10];

int cmp(node a,node b)
{
    return a.y<b.y;
}
int main()
{
    int k=0;
    char a[6];
    while(cin>>a)
    {
        k=1;
        for(int i=0;i<6;i++)
        {
            node1[i].x=' ';
            node1[i].y=0;

        }
        node1[0].x=a[0];
        node1[0].y=1;
        for(int i=1;i<6;i++)
        {
            int mark=0;
            for(int j=0;j<k;j++)
            {
                if(node1[j].x==a[i])
                {
                    node1[j].y++;
                    mark=1;
                    break;
                }
            }
            if(mark==0)
            {
                node1[k].x=a[i];
                node1[k].y++;
                k++;
            }
        }
        if(k==1)  cout<<"1"<<endl;
        else
        {
            sort(node1,node1+k,cmp);
            if(k==2)
            {
                if(node1[0].y==1&&node1[1].y==5)  cout<<"1"<<endl;
                else if(node1[0].y==2&&node1[1].y==4) cout<<"2"<<endl;
                else if(node1[0].y==3&&node1[1].y==3)  cout<<"2"<<endl;
            }
            else if(k==3)
            {
                if(node1[0].y==1&&node1[1].y==1&&node1[2].y==4)  cout<<"2"<<endl;
                else cout<<"3"<<endl;
            }
            else if(k==4)
            {
                if(node1[0].y==1&&node1[1].y==1&&node1[2].y==1&&node1[3].y==3)  cout<<"5"<<endl;
                else cout<<"8"<<endl;
            }
            else if(k==6)  cout<<"30"<<endl;
            else cout<<"24"<<endl;
        }
    }
    return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int kod(vector<int> x){
    sort(x.begin(), x.begin()+6);
    return x[0]*100000 + x[1]*10000 + x[2]*1000 + x[3]*100 + x[4]*10 + x[5]*1;

}

int main(){
    vector<int> x;
    x.resize(6);
    for(int i = 0; i<6; i++) x[i] = 0;
    char znak;
    for(int i=0; i<6; i++){
        cin >> znak;
        if(znak == 'R')x[0]++;
        if(znak == 'O')x[1]++;
        if(znak == 'Y')x[2]++;
        if(znak == 'G')x[3]++;
        if(znak == 'B')x[4]++;
        if(znak == 'V')x[5]++;
    }
    int wynik;
    wynik = kod(x);
    if(wynik == 6) cout <<1;
    if(wynik == 15) cout <<1;
    if(wynik == 24) cout <<2;
    if(wynik == 114) cout <<2;
    if(wynik == 33) cout <<2;
    if(wynik == 123) cout <<4;
    if(wynik == 1113) cout <<8;
    if(wynik == 222) cout <<6;
    if(wynik == 1122) cout <<12;
    if(wynik == 11112) cout <<15;
    if(wynik == 111111) cout <<30;
    return 0;
}

#pragma comment(linker, "/STACK:64000000")
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <sstream>
#include <string.h>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define forv(i, v) forn(i, v.size())

#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

#define pi 3.1415926535897932

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

int perm[2][6] = {{3, 2, 0, 1, 4, 5}, {5, 4, 2, 3, 0, 1}};

set<vector<int> > s;

vector<int> apply(vector<int>& p1, int* p2)
{
    vector<int> r(6);

    forn(i, 6)
    {
        r[i] = p1[p2[i]];
    }

    return r;
}
int main()
{

    vector<int> st;
    forn(i, 6) st.pb(i);

    s.insert(st);

    while (true)
    {
        vector<vector<int> > v(all(s));

        forv(i, v)
        {
            forn(j, 2)
            {
                vector<int> cur = apply(v[i], perm[j]);
                s.insert(cur);
            }
        }

        if (s.size() == v.size()) break;
    }

    assert(s.size() == 24);

    vector<vector<int> > p(all(s));

    string str;
    getline(cin, str);

    set<string> ans;

    do
    {
        string mn = str;

        forv(i, p)
        {
            string cur = "";

            forn(j, 6)
            {
                cur += str[p[i][j]];
            }
            mn = min(mn, cur);
        }

        ans.insert(mn);
    }
    while (next_permutation(all(str)));

    cout << ans.size() << endl;

    return 0;
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define pb push_back
#define mp make_pair
#define tr(s,i) for(vector<int>::iterator i=s.begin();i!=s.end();++i)
typedef vector<int> vi;
typedef vector<int>::iterator vit;
typedef map<string, int> msi;
typedef priority_queue<int> maxh;
typedef priority_queue<int, vector<int>, greater<int> > minh;

int a[9]; // BGORVY

int A(int n) {
    int s = 1;
    for (int i = 1; i <= n; s *= i++);
    return s;
}

int main() {
    int i, n, t;
    string s;
    cin >> s;
    for (i = 0; i < 6; i++) {
        char c = s[i];
        switch (c + 32) {
            case 'b': a[1]++; break;
            case 'g': a[2]++; break;
            case 'o': a[3]++; break;
            case 'r': a[4]++; break;
            case 'v': a[5]++; break;
            case 'y': a[6]++; break;
        }
    }
    sort(a, a + 9, greater<int>());
    if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1 && a[4] == 1 && a[5] == 1) {
        cout << 30 << endl;
    } else if (a[0] == 2 && a[1] == 1 && a[2] == 1 && a[3] == 1 && a[4] == 1 && a[5] == 0) {
        cout << 24 << endl;
    } else if (a[0] == 2 && a[1] == 2 && a[2] == 1 && a[3] == 1 && a[4] == 0 && a[5] == 0) {
        cout << 2 + 9 << endl;
    } else if (a[0] == 2 && a[1] == 2 && a[2] == 2 && a[3] == 0 && a[4] == 0 && a[5] == 0) {
        cout << 1 + 3*1 + 6 << endl;
    } else if (a[0] == 3 && a[1] == 1 && a[2] == 1 && a[3] == 1 && a[4] == 0 && a[5] == 0) {
        cout << 3 + 6 << endl;
    } else if (a[0] == 3 && a[1] == 2 && a[2] == 1 && a[3] == 0 && a[4] == 0 && a[5] == 0) {
        cout << 3 << endl;
    } else if (a[0] == 4 && a[1] == 1 && a[2] == 1) {
        cout << 2 << endl;
    } else if (a[0] == 4 && a[1] == 2) {
        cout << 2 << endl;
    } else if (a[0] == 5 && a[1] == 1) {
        cout << 1 << endl;
    } else if (a[0] == 3 && a[1] == 3) {
        cout << 2 << endl;
    } else if (a[0] == 6) {
        cout << 1 << endl;
    }
    return 0;
}

#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int s = 0;
int a[10];
char str[10];

bool cmp(int a, int b)
{
	if (a < b)
	{
		return false;
	}
	else
	{
		return true;
	}
}

void dfs(int k)
{
	if (k == 5)
	{
		s++;
	}

	int i;

	/*flag = false;
	for (i = 0; i < 6; i++)
	{
		if (a[i] != 0)
		{
			flag = true;
			break;
		}
	}
	if (!flag)
	{
		return;
	}*/
	if (k == 2)
	{
		int mmin = 100;
		int pmin = 0;
		int aa[10];
		for (i = 0; i < 6; i++)
		{
			aa[i] = a[i];
		}
		sort(a, a+6, cmp);
		if (a[0] == 2 && a[1] == 2)
		{
			s += 2;
		}
		else
		{
			for (i = 0; i < 6; i++)
			{
				if (a[i] == 0)
				{
					break;
				}
				/*if (a[i] < mmin)
				{
				pmin = i;
				mmin = a[i];
			}*/
			}
			a[i-1]--;
			dfs(k+1);
		}
		for (i = 0; i < 6; i++)
		{
			a[i] = aa[i];
		}
	}
	else
	{
		for (i = 0; i < 6; i++)
		{
			if (a[i] > 0)
			{
				a[i]--;
				dfs(k+1);
				a[i]++;
			}
		}
	}
}

int main()
{
	while (cin >> str)
	{
		memset(a, 0, sizeof(a));
		int i;
		sort(str, str+6);
		int t = 0;
		a[0] = 1;
		for (i = 1; i < 6; i++)
		{
			if (str[i] == str[i-1])
			{
				a[t]++;
			}
			else
			{
				t++;
				a[t]++;
			}
		}
		if (a[0] == 3 && a[1] == 3)
		{
			cout << 2 << endl;
			continue;
		}
		t++;
		s = 0;
		int mmin = 100;
		int pmin = 0;
		for (i = 0; i < t; i++)
		{
			if (a[i] < mmin)
			{
				pmin = i;
				mmin = a[i];
			}
		}
		a[pmin]--;
		dfs(1);
		/*if (a[0] == 0)
		{
			s *= t-1;
		}
		else
		{
			s *= t;
		}*/
		cout << s << endl;
	}
	return 0;
}

/*
 * Author: kymo
 * Created Time:  2011/7/22 23:33:25
 * File Name: 3.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string.h>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define F(a,b) for(int i = a;i <= b;i ++)
#define int_max 99999999999LL
#define eps 1.0e-6
#define max 100
string aa;
int visited[max];
char str[7] = {'R','O','Y','G','B','V'};
int c(int n,int m){
    if(m == 0) return 1;
    else return (n*c(n-1,m-1))/m;
}
int a[max];
int main() {
    cin>>aa;
    int  N = 0;
    for(int j = 0;j <= 5;j ++){
        visited[j] = 0;
        for(int l = 0;l <= aa.length()-1;l ++){
            if(str[j] == aa[l]){
                visited[j] ++;
            }
        }
    }
    int count = 0;
    for(int j = 0;j <= 5;j ++){
        if(visited[j]!=0) a[count ++] = visited[j];
    }
    if(count == 1) cout<<1<<endl;
    else if(count == 6) cout<<30<<endl;
    else if(count == 5) cout<<15<<endl;
    else if(count == 4){
        int flag = 0;
        for(int j = 1;j <= count; j++){
            if(a[j] == 3) {
                flag = 1;
                break;
            }
        }
        if(!flag) cout<<8<<endl;
        else cout<<5<<endl;
    }
    else if(count == 3){
        int flag = 1;
        for(int j = 1;j <= count;j ++){
            if(a[j] == 3){
                flag = 0;
                break;
            }
        }
        if(flag) cout<<3<<endl;
        else cout<<6<<endl;
    }
    else if(count == 2){
        int ff = 0;
        for(int j = 1;j <= count;j ++){
            if(a[j] == 3){
                cout<<2<<endl;
                break;
            }
            if(a[j] == 1){
                cout<<1<<endl;
                break;
            }
            if(a[j] == 2){
                cout<<2<<endl;
                break;
            }
        }
    }
    return 0;
}

    #include<cstdio>
    #include<algorithm>
    #include<iostream>
    using namespace std;
    char c[10];
    int vis[30];
    int dir[10],lab;
    int main()
    {

        cin>>c;
        for(int i=0;c[i];i++)
            vis[c[i]-'A']++;
        for(int i=0;i<26;i++)
            if(vis[i])
                dir[lab++]=vis[i];
        sort(dir,dir+lab);
        if(dir[lab-1]==1)
            cout<<"30"<<endl;//T
        else if(dir[lab-1]==2)
        {
            if(lab==5)
                cout<<"15"<<endl;
            else if(lab==4)
                cout<<"5"<<endl;
            else
                cout<<"5"<<endl;
        }
        else if(dir[lab-1]==3)
        {
            if(lab==4)
                cout<<"4"<<endl;
            else if(lab==3)
                cout<<"3"<<endl;
            else
                cout<<"2"<<endl;//T
        }
        else if(dir[lab-1]==4)
            cout<<"2"<<endl;//T
        else
            cout<<"1"<<endl;//T
    }

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<iomanip>
#include<set>

using namespace std;
const int maxn=100000;

int main(){
    char f[6];
    cin>>f;
    set<char>M;
    for(int i=0;i<6;++i)
        M.insert(f[i]);
    switch(M.size()){
        case 1: cout<<1<<endl; break;
        case 6: cout<<30<<endl; break;
        case 2: {
            char a=f[0];
            int x=1;
            for(int i=1;i<6;++i)
                if(f[i]==a)x++;
            if(x==1||x==5)cout<<1<<endl;
            else cout<<2<<endl;
            break;
        }
        case 3:{
            char a=f[0],b;
            int x=1,y=0;
            for(int i=1;i<6;++i){
                if(f[i]==a)x++;
                else if(!y)b=f[i],y++;
                else if(f[i]==b)y++;
            }
            //if(x==y)
                cout<<3<<endl;
            //else cout<<2<<endl;
            break;
        }
        case 4:{
            char a,b,c;
            int x=0,y=0,z=1;
            for(int i;i<6;++i){
                if(f[i]==a)z++;
                else if(!x||f[i]==b)++x,b=f[i];
                else if(!y||f[i]==c)++y,c=f[i];
            }
            if(x==3||y==3||x+y==3)cout<<5<<endl;
            else cout<<8<<endl;
            break;
        }
        case 5:cout<<15<<endl;break;
    }
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
bool cmp(int a,int b){return a>b;}
int main()
{
    int sum[6]={0,0,0,0,0,0};
    char s[7];
    cin>>s;
    for(int i=0;i<7;i++)
    {
        if(s[i]=='R')sum[1]++;
        if(s[i]=='O')sum[2]++;
        if(s[i]=='Y')sum[3]++;
        if(s[i]=='G')sum[4]++;
        if(s[i]=='B')sum[5]++;
        if(s[i]=='V')sum[0]++;
    }
    sort(sum,sum+6,cmp);
    int ans=0;
    if(sum[0]==6)ans=1;
    else if(sum[0]==5)ans=1;
    else if(sum[0]==4)
    {
        if(sum[1]==2)ans=2;
        if(sum[1]==1)ans=2;
    }
    else if(sum[0]==3)
    {
        if(sum[1]==3)ans=2;
        if(sum[1]==2)ans=3;
        if(sum[1]==1)ans=4;
    }
    else if(sum[0]==2)
    {
        if(sum[1]==2)
        {
            if(sum[2]==2)ans=6;
            if(sum[2]==1)ans=6;
        }
        if(sum[1]==1)ans=15;
    }
    else if(sum[0]==1)ans=30;
cout<<ans<<endl;
}

#define _CRT_SECURE_NO_WARNINGS
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstdio>
#include <complex>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
using namespace std;

int a[][5] =
{
	{ 2, 3, 4, 5, 1 },
	{ 2, 3, 4, 5, 0 },
	{ 0, 5, 1, 3, 4 },
	{ 0, 2, 1, 4, 5 },
	{ 0, 5, 1, 3, 2 },
	{ 0, 2, 1, 4, 3 },
};

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	string s; cin >> s;
	set < string > all;
	sort(s.begin(), s.end());
	while (true)
	{
		string res = s;
		for (int i = 0; i < 6; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				string t = string() + s[i] + s[a[i][4]];
				for (int d = -1; d < 2; d += 2)
				{
					string p = t;
					for (int k = 0; k < 4; k++) p += s[a[i][(j + k * d + 4) % 4]];
					res = min(res, p);
				}
			}
		}
		all.insert(res);
		if (!next_permutation(s.begin(), s.end())) break;
	}
	cout << all.size();
	return 0;
}

//AcFreak

#include<bits/stdc++.h>
#define lint long long int
#define mp make_pair
#define pb push_back
#define f first
#define INF (lint )(1e9)
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define s second
#define endl '\n'
#define pii pair<int,int >
using namespace std;
struct pair_hash {
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1,T2> &p) const {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);

        return h1 ^ h2;
    }
};

unordered_map<string ,int >visited;
void generator(string name)
{
    string a,b,c;
    a=name.substr(0,2);
    b=name.substr(2,2);
    c=name.substr(4,2);
    string d,e,f;
    for(int i=0;i<8;i++)
    {
        int tt=i;
        if(tt%2 ==0)
        {
            d=a;
        }
        else
        {
            d=a;
            reverse(d.begin(), d.end());
        }
        tt/=2;
        if(tt%2 ==0)
        {
            e=b;
        }
        else
        {
            e=b;
            reverse(e.begin(), e.end());
        }
        tt/=2;
        if(tt%2 ==0)
        {
            f=c;
        }
        else
        {
            f=c;
            reverse(f.begin(), f.end());
        }
        visited[d+e+f]=1;
        visited[d+f+e]=1;
        visited[e+d+f]=1;
        visited[e+f+d]=1;
        visited[f+d+e]=1;
        visited[f+e+d]=1;
    }

}

int main()
{__

        string name;
        cin>>name;

        set<string >ss;
        sort(name.begin(),name.end());
        do
        {
            ss.insert(name);
        }while(next_permutation(name.begin(),name.end()));

        for(auto it=ss.begin();it!=ss.end();it++)
        {
            visited[*it]=0;
        }

        int ans=0;
        for(auto it=ss.begin();it!= ss.end();it++)
        {
            if(visited[*it] == 1)
                continue;

      //cout<<*it<<endl;
            ans++;

            generator(*it);
        }
        cout<<ans<<endl;
      return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

string f(string s)
{
	string result=s;
	rep(i,6){
		string t=s;
		rotate(t.begin(),t.begin()+i,t.end());
		char c;
		c=t[1];t[1]=t[2];t[2]=t[4];t[4]=t[5];t[5]=c;result=min(result,t);
		c=t[1];t[1]=t[2];t[2]=t[4];t[4]=t[5];t[5]=c;result=min(result,t);
		c=t[1];t[1]=t[2];t[2]=t[4];t[4]=t[5];t[5]=c;result=min(result,t);
		c=t[1];t[1]=t[2];t[2]=t[4];t[4]=t[5];t[5]=c;result=min(result,t);
	}
	return result;
}

int main()
{
	for(string s;cin>>s && s!="#";){
		set<string> res;
		sort(allof(s));
		do{
			res.insert(f(s));
		}while(next_permutation(allof(s)));
		cout<<res.size()<<endl;
	}

	return 0;
}

#include <stdio.h>
#include <iostream>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <algorithm>

using namespace std;

#define file "file"
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAXN = 1e4+5;
const double EPS = 1e-8;
const ll INF = 1000000000+5;
const int MAXN2 = 1e6+2;

char s[MAXN];
string a[MAXN][10];
string b[10];
bool rev[10];

int d1[4]={0,1,2,3};
int d2[4]={4,0,5,2};
int d3[4]={4,1,5,3};
int p[6];

bool same(int i)
{
	for(int j=0;j<6;j++)
	{
		next_permutation(p,p+3);
		int f1 = b[0].find(a[i][p[0]]);
		int f2 = b[1].find(a[i][p[1]]);
		int f3 = b[2].find(a[i][p[2]]);
		if(f1>=0 && f2>=0 && f3>=0)
		{
			return true;
		}
	}

	return  false;
}

int main()
{
	//freopen(file".in","r",stdin); freopen(file".out","w",stdout);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	gets(s);

	for(int i=0;i<3;i++) p[i] = i;

	set<char> st;
	for(int i=0;i<6;i++) st.insert(s[i]);

	if(st.size()==6)
	{
		printf("30");
		return 0;
	}
	int cnt = 0;
	for(int i=0;i<720;i++)
	{
		next_permutation(s,s+6);
		b[0] = "";
		b[1] = "";
		b[2] = "";
		for(int j=0;j<4;j++)
		{
			b[0]+= s[d1[j]];
		}
		b[0]+=b[0];

		for(int j=0;j<4;j++)
		{
			b[1]+= s[d2[j]];
		}
		b[1]+=b[1];

		for(int j=0;j<4;j++)
		{
			b[2]+= s[d3[j]];
		}
		b[2]+=b[2];

		bool was = false;
		for(int j=0;j<cnt;j++)
		{
			if(same(j))
			{
				was = true;
				break;
			}
		}

		if(!was)
		{
			rev[0] = rev[1] = rev[2] = 0;
			for(int h=0;h<8;h++)
			{
				for(int k=0;k<3;k++)
				{
					if(h&(1<<k))
					{
						if(!rev[k])
						{
							rev[k] = true;
							for(int j=0;j<2;j++)
							{
								swap(b[k][j],b[k][3-j]);
								swap(b[k][4+j],b[k][7-j]);
							}
						}
					}
					else
					{
						if(rev[k])
						{
							rev[k] = 0;
							for(int j=0;j<2;j++)
							{
								swap(b[k][j],b[k][3-j]);
								swap(b[k][4+j],b[k][7-j]);
							}
						}
					}
				}

				for(int j=0;j<cnt;j++)
				{
					if(same(j))
					{
						was = true;
						break;
					}
				}
			}
		}

		if(!was)
		{
			for(int j=0;j<3;j++)
			{
				a[cnt][j] = "";
				for(int h=0;h<4;h++)
				{
					a[cnt][j]+=b[j][h];
					//printf("%1c",b[j][h]);
				}
				//printf("\n");
			}
			//printf("\n");
			cnt++;
		}
	}

	printf("%d",cnt);
	return 0;
}