链接:​​https://www.nowcoder.com/acm/contest/156/D​​​

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#define mem(a,x) memset(a,x,sizeof(a))
#define s1(x) scanf("%d",&x)
#define s2(x,y) scanf("%d%d",&x,&y)
#define s3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define s4(x,y,z,k) scanf("%d%d%d%d",&x,&y,&z,&k)
#define ff(a,n) for(int i = 0 ; i < n; i++) scanf("%d",a+i)
#define tp(x) printf("x = %d\n",x)
#define ansp(x) printf("%d\n",x)
//inline ll ask(int x){ll res=0;while(x)res+=c[x],x-=x&(-x);return res;}
//inline void add(int x,int d){while(x<=n)c[x]+=d,x+=x&(-x);}
#define ls 2*rt
#define rs 2*rt+1
#define lson ls,L,mid
#define rson rs,mid+1,R
#define ll long long
using namespace std;
typedef pair<int,int> pii;
const ll inf = 0x3f3f3f3f;

const int mx = 3400;
int ne[mx][20];
char a[] ="abcdefghi";
char s[mx];
int main(){
//int T=10; scanf("%d",&T);
// freopen("F:\\in.txt","r",stdin);
scanf("%s",s+1);
int len = strlen(s+1);
mem(ne,0);
for(int i = len ; i > 0; i--){
for(int j= 0; j < 9; j++)
ne[i-1][j] = ne[i][j];
ne[i-1][s[i]-'a'] = i;
}
/* for(int i = 1 ; i <= len; i++){
if(!first[s[i]-'a'])
first[s[i]-'a'] = i;
}*/
int co,ob,pos,ans=0;
do{
//printf("字符串 = %s\n",a);
pos = 0;
co = 0;
ob = ne[0][a[0]-'a'];
while(ob != 0&&co < 9){ //这里错写小于等于
co++;
ob = ne[ob][a[++pos]-'a'];
}
// cout<<"co="<<co<<endl;
if(co == 9)
ans++;
}
// while(0);
while(next_permutation(a,a+9));

cout<<ans<<endl;



return 0;
}