This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any sleep this night at all.

In the morning, Vasya was waiting the bus to the university on the bus stop. Vasya's thoughts were hazy and so he couldn't remember the right bus' number quite right and got onto the bus with the number $n$.

In the bus, Vasya thought that he could get the order of the digits in the number of the bus wrong. Futhermore, he could "see" some digits several times, but the digits he saw were definitely in the real number of the bus. For example, if Vasya saw the number 2028, it could mean that the real bus number could be 2028, 8022, 2820 or just 820. However, numbers 80, 22208, 52 definitely couldn't be the number of the bus. Also, real bus number couldn't start with the digit 0, this meaning that, for example, number 082 couldn't be the real bus number too.

Given $n$, determine the total number of possible bus number variants.


-----Input-----

The first line contains one integer $n$ ($1 \leq n \leq 10^{18}$) — the number of the bus that was seen by Vasya. It is guaranteed that this number does not start with $0$.


-----Output-----

Output a single integer — the amount of possible variants of the real bus number.


-----Examples-----
Input
97

Output
2

Input
2028

Output
13



-----Note-----

In the first sample, only variants $97$ and $79$ are possible.

In the second sample, the variants (in the increasing order) are the following: $208$, $280$, $802$, $820$, $2028$, $2082$, $2208$, $2280$, $2802$, $2820$, $8022$, $8202$, $8220$.

Difficulty: interview

Starter code:

Solutions:
n=input()
rg=[0]*10
for i in n: rg[int(i)]+=1
rl=[]
ff=0
for i in range(len(rg)):
    if rg[i]!=0:
        rl.append(rg[i])
        if i==0: ff=1
fact=[1]
fc=1
for i in range(1,20):
    fc*=i
    fact.append(fc)
rt=[]
t=0
def cfs(d):
    if d==len(rl):
        nonlocal t,ff
        jj=fact[sum(rt)]
        for i in rt: jj=jj/fact[i]
        if ff:
            jjj=fact[sum(rt)-1]
            jjj=jjj/fact[rt[0]-1]
            for i in range(1,len(rt)): jjj=jjj/fact[rt[i]]
            jj-=jjj
        t+=jj
        return
    
    for i in range(1,rl[d]+1):
        rt.append(i)
        cfs(d+1)
        rt.pop(-1)

cfs(0)
print(int(t))


        
            
    

'''
////////////////      //////        ///////      //             ///////     //  //   //
////          //    ///   ///     ///    ///     //            ///  ///     ////     //
////    ////       ///     ///   ///      ///    //           /////////     ////     ///////
////     /////    ///       /// ///        ///   //          ///    ///     ////     //   //
//////////////     ///////////   ///////////     //////     ///     ///     //  //   //   //
'''



N = input()

C = [0]*10
for n in N:
    C[int(n)] += 1

memo = {}
def dfs(i, state):
    key = tuple(state)
    if key in memo:
        return memo[key]
    r = 0
    if all(s == 0 or 1 <= t for s, t in zip(C, state)):
        r += 1
    for j in range(10):
        if C[j] - state[j] > 0:
            state[j] += 1
            r += dfs(i+1, state)
            state[j] -= 1
    memo[key] = r
    return r
state = [0]*10
ans = 0
for i in range(1, 10):
    if C[i] > 0:
        state[i] += 1
        ans += dfs(1, state)
        state[i] -= 1
print(ans)

from collections import Counter
from itertools import product

s = input()

ds = Counter(s)


fac = [1 for i in range(100)]
for i in range(1, 100):
    fac[i] = fac[i-1] * i

res = 0
for possib in product(*[list(zip([k] * n, list(range(1, n+1)))) for k, n in list(ds.items())]):
    possib = list(possib)
    non_zero_sum = sum(v for k, v in possib if k != '0')
    total = sum(v for _, v in possib)

    value = non_zero_sum * fac[total-1]
    for _, v in possib:
        value //= fac[v]

    res += value
print(res)


import itertools as it
S=input().strip()
freq=[0 for i in range(10)]
for i in S:
    u=ord(i)-ord('0')
    freq[u]+=1

fac=[1]
for i in range(1,20): fac.append(i*fac[-1])

"""
M={}
def F(cur,used):
    while cur<10 and freq[cur]==0: cur+=1
    if cur==10:
        r=fac[sum(used)]
        for i in used:
            r//=fac[i]
        print(used)
        return 1

    key=(cur,tuple(used))
    if key in M: return M[key]
    
    r=0
    for i in range(1,freq[cur]):
        for j in range(
    return r

total=0
for i in range(1,10):
    if freq[i]==0: continue
    M={}
    freq[i]-=1
    used=[0 for j in range(10)]
    used[i]=1
    total+=F(0,used)
    freq[i]+=1

print(total)
"""

total=0
for x in it.product(*(list(range(0 if i==0 else 1,i+1)) for i in freq)):
    Q="".join(str(i)*x[i] for i in range(10))
    s=sum(x)-1
    if s<0: continue
    g=0
    for d in range(1,10):
        n=fac[s]
        y=list(x)
        y[d]-=1
        #assert(s==sum(y))
        for k in range(0,10):
            n//=fac[y[k]]
        g+=n
        #print(x,d,n,g)
    #print(Q,x,g)
    total+=g

print(total)

#208
#280
#802
#820
#2028, 2082, 2208, 2280, 2802, 2820
#8022, 8202, 8220


import itertools as it


def factorial(n):
    i = 1
    for j in range(1, n + 1):
        i *= j
    return i


def C(n, k):
    k = max([k, n - k])
    result = 1
    for i in range(k + 1, n + 1):
        result *= i
    result //= factorial(n - k)
    return result



n = input()


digits = [0 for _ in range(10)]

for i in n:
    digits[int(i)] += 1

result = 0

for amounts in it.product(*[[0] if x == 0 else list(range(1, x + 1)) for x in digits]):
    sum_no_zero = sum(amounts[1:])
    if sum_no_zero == 0:
        continue
    #print(amounts)
    tmp = factorial(sum_no_zero)
    for j in amounts[1:]:
        tmp //= factorial(j)
    tmp *= C(sum_no_zero + amounts[0] - 1, amounts[0])
    result += tmp


print(result)


n=int(input())
t=[]
a=[]
for i in range(10):
    t.append(0)
    a.append(1)
while n:
    a[n%10]+=1
    n//=10
ans=0
for i in range(a[0]!=1,a[0]):
    t[0]=i
    for i in range(a[1]!=1,a[1]):
        t[1]=i
        for i in range(a[2]!=1,a[2]):
            t[2]=i
            for i in range(a[3]!=1,a[3]):
                t[3]=i
                for i in range(a[4]!=1,a[4]):
                    t[4]=i
                    for i in range(a[5]!=1,a[5]):
                        t[5]=i
                        for i in range(a[6]!=1,a[6]):
                            t[6]=i
                            for i in range(a[7]!=1,a[7]):
                                t[7]=i
                                for i in range(a[8]!=1,a[8]):
                                    t[8]=i
                                    for i in range(a[9]!=1,a[9]):
                                        t[9]=i
                                        s=0
                                        for i in range(10):
                                            s+=t[i]
                                        w=1
                                        cnt=s
                                        for i in range(10):
                                            for j in range(t[i]):
                                                if i==0:w*=cnt-1
                                                else:w*=cnt
                                                cnt-=1
                                        for i in range(10):
                                            for j in range(1,t[i]+1):
                                                w//=j
                                        #print(w)
                                        ans+=w
print(ans)


n = int(input())
s = str(n)

ans = 0
a = [s.count(str(digit)) for digit in range(10)]

from math import factorial
from functools import reduce
from operator import mul

def get(*args):
	res = factorial(sum(args))
	for x in args:
		res //= factorial(x)
	return res

for a0 in range(0 if not a[0] else 1, a[0] + 1):
	for a1 in range(0 if not a[1] else 1, a[1] + 1):
		for a2 in range(0 if not a[2] else 1, a[2] + 1):
			for a3 in range(0 if not a[3] else 1, a[3] + 1):
				for a4 in range(0 if not a[4] else 1, a[4] + 1):
					for a5 in range(0 if not a[5] else 1, a[5] + 1):
						for a6 in range(0 if not a[6] else 1, a[6] + 1):
							for a7 in range(0 if not a[7] else 1, a[7] + 1):
								for a8 in range(0 if not a[8] else 1, a[8] + 1):
									for a9 in range(0 if not a[9] else 1, a[9] + 1):
										ans += get(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9)
										if a0:
											ans -= get(a0 - 1, a1, a2, a3, a4, a5, a6, a7, a8, a9)
print(ans)


3

def enc(t):
    v = 0
    for x in t:
        v *= 20
        v += x
    return v


def dec(v, N):
    a = []
    for _ in range(N):
        a.append(v % 20)
        v //= 20
    a.reverse()
    return a


def cnt(C, ld, ud):
    N = len(C)

    ans = 0

    dp = {enc([0] * N): 1}
    for rnd in range(ud):
        if rnd >= ld:
            for et in dp:
                c = dp[et]
                t = dec(et, N)
                if ((C[0] == 0 and all([t[i] >= 1 for i in range(1, N)]))
                    or (C[0] > 0 and all([t[i] >= 1 for i in range(N)]))):
                    ans += c

        ndp = {}

        for et in dp:
            t = dec(et, N)
            c = dp[et]

            for i in range(N):
                if rnd == 0 and i == 0:
                    continue
                if t[i] < C[i]:
                    l = list(t)
                    l[i] += 1
                    nt = enc(l)
                    if nt not in ndp:
                        ndp[nt] = 0
                    ndp[nt] += c

        dp = ndp

    for et in dp:
        c = dp[et]
        t = dec(et, N)
        if ((C[0] == 0 and all([t[i] >= 1 for i in range(1, N)]))
            or (C[0] > 0 and all([t[i] >= 1 for i in range(N)]))):
            ans += c

    return ans


def solve(S):
    N = len(S)
    C = [0] * 10
    for c in S:
        C[ord(c) - ord('0')] += 1

    mindigits = len([c for c in C if c > 0])

    C = [C[0]] + [C[i] for i in range(1, 10) if C[i] > 0]

    return cnt(C, mindigits, N)


def main():
    S = input()
    print(solve(S))


def __starting_point():
    main()

__starting_point()

n = input()
facts = {0: 1}

def fact(a):
	nonlocal facts
	if a in facts:
		return facts[a]
	res = 1
	for i in range(1, a+1):
		res *= i
		facts[i] = res
	return facts[a]

occ = [0] * 10
for i in range(len(n)):
	occ[int(n[i])] += 1

ans = 0

def go_find(hame, start):
#	print("Start: " + str(start))
#	print(hame)
	nonlocal ans
	if hame[0] == 0:
		res = fact(sum(hame))
		for i in range(10):
			res //= fact(hame[i])
	else:
		res2 = fact(sum(hame)-1)
		for i in range(1, 10):
			res2 //= fact(hame[i])
		res2 //= fact(hame[0]-1)
		
		res = fact(sum(hame))
		for i in range(10):
			res //= fact(hame[i])

		res -= res2

#	print(res)
#	print("=============")
	ans += res
	for i in range(start, 10):
		if hame[i] > 1:
			hame[i] -= 1
			go_find(hame, i)
			hame[i] += 1

go_find(occ, 0)
print(ans)
	



s = input()
cnt = [0 for i in range(10)]
for c in s:
	cnt[ord(c) - ord('0')] += 1
dp = [0 for i in range(20)]	
dp[0] = 1
comb = [[0 for i in range(40)] for j in range(40)]
for i in range(40):
	for j in range(i + 1):
		if i == j or j == 0:
			comb[i][j] = 1
		else:
			comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1]

for dig in [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]:
	if cnt[dig] == 0:
		continue
	odp = dp
	dp = [0] * 20
	for lsz in range(20):
		for pick in range(1, cnt[dig] + 1):
			if (lsz + pick < 20):
				m = lsz + (dig != 0) + pick - 1
				r = lsz + (dig != 0) - 1
				ways = 0
				if (m == r):
					ways = 1
				elif (r > m or r < 0 or m < 0):
					ways = 0
				else:
					ways = comb[m][r]
				dp[lsz + pick] += odp[lsz] * ways

res = 0
for i in range(1, 20):
	res += dp[i]
print(res)



from collections import defaultdict as dd
from math import factorial as f

s = input()

cnt = dd(int)

for i in s:
    cnt[i] += 1

ans = 0

def calc(cur_chr, dem, do_not_take_sum, total, diff):
    nonlocal ans
    nonlocal cnt

    if cur_chr == '9':
        for do_not_take in range(0, cnt[cur_chr] + 1):
            if do_not_take > 0 and do_not_take == cnt[cur_chr]:
                continue

            cur_do_not_take_sum = do_not_take_sum + do_not_take
            if cur_do_not_take_sum == total:
                continue

            cur_dem = dem * f(cnt[cur_chr] - do_not_take)
            num = f(total - cur_do_not_take_sum)

            ans += num // cur_dem * diff
        return

    for do_not_take in range(0, cnt[cur_chr] + 1):
        if do_not_take > 0 and do_not_take == cnt[cur_chr]:
            if not(diff == -1 and cur_chr == '0'):
                continue
        calc(chr(ord(cur_chr) + 1), dem * f(cnt[cur_chr] - do_not_take), do_not_take_sum + do_not_take, total, diff)

calc('0', 1, 0, len(s), 1)

if cnt['0'] != 0:
    cnt['0'] -= 1
    calc('0', 1, 0, len(s) - 1, -1)

print(ans)


def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())

fact = [1] * 1000
for i in range(2, 1000):
    fact[i] = fact[i - 1] * i

s = input()
cnt = {}
for d in '0123456789':
    cnt[int(d)] = s.count(d)
ans = 0

def getcnt(p):
    q = [pi for pi in p if pi != 0]
    num = fact[sum(q)]
    den = 1
    for qi in q:
        den *= fact[qi]
    gc = num // den
    if p[0]:
        q = [pi for pi in p if pi != 0]
        q[0] -= 1
        num = fact[sum(q)]
        den = 1
        for qi in q:
            den *= fact[qi]
        gc -= num // den
    #print(p, gc)
    return gc

def rec(d, p):
    nonlocal ans
    if d == 10:
        ans += getcnt(p)
        return
    if cnt[d] == 0:
        p[d] = 0
        rec(d + 1, p)
        return
    for c in range(1, cnt[d] + 1):
        p[d] = c
        rec(d + 1, p)

p = [0] * 10
rec(0, p)

print(ans)

n=input()
s=[0 for i in range(10)]
for i in n:
    s[int(i)]+=1

nol=s[0]
del s[0]
#while 0 in s:
#    s.remove(0)
def C(n,k): # C(10,2)=45
    def fact(k):
        s=1
        for i in range(1,k+1):
            s*=i
        return s
    return fact(n)/(fact(k)*fact(n-k))
def var(nol, koeff):
    def C(n,k): # C(10,2)=45
        def fact(k):
            s=1
            for i in range(1,k+1):
                s*=i
            return s
        return fact(n)/(fact(k)*fact(n-k))
    n=0
    if nol!=0:
        koeff.append(nol)
    for i in koeff:
        n+=i
    s=1
    for k in koeff:
        s*=C(n, k)
        n-=k
    if nol!=0:
        koeff.remove(nol)
        nol-=1
        koeff.append(nol)
        s2=1
        n=0
        for i in koeff:
            n+=i
        for k in koeff:
            s2*=C(n,k)
            n-=k
        s-=s2
    return s
c=0
nado=len(s)-s.count(0)
if nol!=0:
    counter=1
else:
    counter=0
for nolik in range(nol+1):
    for c1 in range(s[0]+1):
        for c2 in range(s[1]+1):
            for c3 in range(s[2]+1):
                for c4 in range(s[3]+1):
                    for c5 in range(s[4]+1):
                        for c6 in range(s[5]+1):
                            for c7 in range(s[6]+1):
                                for c8 in range(s[7]+1):
                                    for c9 in range(s[8]+1):
                                        koeff=[c1,c2,c3,c4,c5,c6,c7,c8,c9]
                                        while 0 in koeff:
                                            koeff.remove(0)
                                        if len(koeff)==nado:
                                            if counter==1 and nolik>=1 or counter==0:
                                                c+=var(nolik, koeff)
print(int(c))

a = list(map(int,input()));
cnts = [0]*10;
for aa in a:
    cnts[aa]+=1

mem = {}

mem[(1,0,0,0,0,0,0,0,0,0)] = 0;

for i in range(1,10):
   mem[(0,)*(i) + (1,) + (0,)*(10-i-1)] = 1;

def get(a):
    if (tuple(a) in mem):
        return mem[tuple(a)]
    else:
        aa = list(a)
        tot = 0
        for i in range(0,10):
            if (a[i] != 0):
                aa[i] -= 1;
                tot += get(aa);
                aa[i] += 1;
        mem[tuple(a)] = tot
        return tot

bigTot = 0

def goThrough(pre, post):
    nonlocal bigTot
    if (len(post) == 0) :
        bigTot += get(pre)
    elif (post[0] == 0):
        goThrough(pre + (0,) , post[1:])
    else:
        for i in range(1,post[0]+1):
            goThrough(pre + (i,) , post[1:])



goThrough((), cnts)

print(bigTot)



def main():
    ast = []
    def fact(x):
        if x == 0:
            return 1
        return x * fact(x - 1)
    n = input()
    def helper(dc):
        a = 0
        temp = [dc[j] for j in dc if j != '0']
        s = sum(temp)
        try:
            ret = fact(s) * fact(s + dc['0'] - 1) // (fact(s - 1) * fact(dc['0']))
        except:
            ret = fact(s)
        for i in temp:
            ret = ret // fact(i)
        for i in dc:
            if dc[i] != 1:
                d = {}
                for j in dc:
                    d[j] = dc[j]
                d[i] -= 1
                if str(d) not in ast:
                    ast.append(str(d))
                    a += helper(d)
        return ret + a
    dct = {}
    for i in set(n):
        dct[i] = n.count(i)
    print(helper(dct))
    return 0
main()


ct=[0]*10
fact=[1]*20
ans=0
def setAns(lol):
    nonlocal ans
    ans=lol

def calc(k,fr):
    if(k==10):
        # print(fr)
        tot=sum(fr)
        w0=fact[tot]
        # print(tot,w0)
        for i in range(10):
            w0//=fact[fr[i]]
        wo0=0
        if(fr[0]>0):
            fr[0]-=1
            wo0=fact[tot-1]
            for i in range(10):
                wo0//=fact[fr[i]]
            fr[0]+=1
        tp=w0-wo0
        # print(w0,wo0)
        setAns(ans+tp)
        return
    if(ct[k]==0):
        calc(k+1,fr)
        return 
    for i in range(1,ct[k]+1):
        # print(k,i)
        fr[k]=i
        calc(k+1,fr)

fact[0]=1
for i in range(1,20):
    fact[i]=fact[i-1]*i
n=int(input())
while(n>0):
    k=n%10
    n//=10
    ct[k]+=1
freq=[0]*10
calc(0,freq)
print(ans)

from collections import defaultdict
from copy import deepcopy

a = list(input())

d = defaultdict(int)
for x in a:
    d[int(x)] += 1

fact_mem = {}


def fact(n):
    if n in fact_mem:
        return fact_mem[n]
    ans = 1
    for i in range(1, n + 1):
        ans *= i
    fact_mem[n] = ans
    return ans


mem = {}


def f(d):
    tmp = frozenset(list(d.items()))
    if tmp in mem:
        return 0
    n = sum(d.values())
    ans = 0
    if d[0] > 0:
        ans += (n - d[0]) * fact(n - 1)
    else:
        ans += fact(n)
    if len(d) == 1 and d[0] > 0:
        return 0
    for x in d:
        ans //= fact(d[x])
    for k in d:
        if d[k] > 1:
            e = deepcopy(d)
            e[k] -= 1
            ans += f(e)
    mem[frozenset(list(d.items()))] = ans
    return ans


ans = f(d)
print(ans)


a = int(input())
b = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
while a != 0:
    b[a % 10] += 1
    a //= 10

ans = 0

def fact(n):
    f = 1
    for i in range(1, n + 1):
        f *= i
    return f

def f(n, arr):
    #print(arr)
    nonlocal ans
    if n == 10:
        sum = 0
        for i in range(10):
            sum += arr[i]
        temp = 1
        temp *= sum - arr[0]
        #print(temp)
        temp *= fact(sum - 1)
        #print(temp)
        for i in range(10):
            if arr[i] > 1:
                temp //= fact(arr[i])
        
        ans += temp
        #print(ans)
    else:
        if b[n] > 0:
            for i in range(1, b[n] + 1):
                temp = arr.copy()
                temp.append(i)
                f(n + 1, temp)
        else:
            arr.append(0)
            f(n + 1, arr)


f(0, [])
print(int(ans))

n = input()
all = [0] * 10
for x in n:
	all[int(x)]+=1

dp = [0] * 20
dp[0] = 1
for i in range(1, 10):
	cur = [0] * 20
	if(all[i] > 0):
		for le in range(0, 20):     
			fac = 1
			zn = 1
			for kol in range(1, all[i] + 1):
				if(le + kol < 20):
					zn *= le + kol
					fac *= kol
					cur[le + kol] +=  (zn // fac) * dp[le]
		dp = cur


cur = [0] * 20
if(all[0] > 0):
	for le in range(1, 20):
		fac = 1
		zn = 1
		for kol in range(1, all[0] + 1):
			if(le + kol < 20):
				zn *= (le + kol-1)
				fac *= kol
				cur[le + kol] +=  (zn // fac) * dp[le]
	dp = cur

print(sum(dp))


def fact(n):
    nonlocal fa
    if fa[n] != -1:
        return fa[n]
    else:
        fa[n] = fact(n - 1) * n
        return fa[n]
fa = [-1] * 20
fa[0] = 1
fa[1] = 1
fa[2] = 2

res = 0

a = int(input())
b = str(a)
s = [0] * 10
for i in range(len(b)):
    s[int(b[i])] += 1
    
for i0 in range(s[0] + 1):
    if i0 > 0 or s[0] == 0:
        for i1 in range(s[1] + 1):
            if i1 > 0 or s[1] == 0:
                for i2 in range(s[2] + 1):
                    if i2 > 0 or s[2] == 0:
                        for i3 in range(s[3] + 1):
                            if i3 > 0 or s[3] == 0:
                                for i4 in range(s[4] + 1):
                                    if i4 > 0 or s[4] == 0:
                                        for i5 in range(s[5] + 1):
                                            if i5 > 0 or s[5] == 0:
                                                for i6 in range(s[6] + 1):
                                                    if i6 > 0 or s[6] == 0:
                                                        for i7 in range(s[7] + 1):
                                                            if i7 > 0 or s[7] == 0:
                                                                for i8 in range(s[8] + 1):
                                                                    if i8 > 0 or s[8] == 0:
                                                                        for i9 in range(s[9] + 1):
                                                                            if i9 > 0 or s[9] == 0:
                                                                                w2 = [i0, i1, i2, i3, i4, i5, i6, i7, i8, i9]
                                                                                su = 0
                                                                                for i in range(10):
                                                                                    su += w2[i]
                                                                                for i in range(1, 10):
                                                                                    if w2[i] > 0:
                                                                                        w2[i] -= 1
                                                                                        su -= 1
                                                                                        
                                                                                        res += fact(su)/(fact(w2[0]) * fact(w2[1]) * fact(w2[2]) * fact(w2[3]) * fact(w2[4]) * fact(w2[5]) * fact(w2[6]) * fact(w2[7]) * fact(w2[8]) * fact(w2[9]))
                                                                                        
                                                                                        su += 1
                                                                                        w2[i] += 1
print(int(res))    

a = int(input())
b = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
while a != 0:
    b[a % 10] += 1
    a //= 10

ans = 0

def gao(n):
    f = 1
    for i in range(1, n + 1):
        f *= i
    return f

def shit(n, arr):
    nonlocal ans
    if n == 10:
        sum = 0
        for i in range(10):
            sum += arr[i]
        gg = sum - arr[0]
        gg *= gao(sum - 1)
        for i in range(10):
            if arr[i] > 1:
                gg //= gao(arr[i])
        ans += gg
    else:
        if b[n] > 0:
            for i in range(1, b[n] + 1):
                gg = arr.copy()
                gg.append(i)
                shit(n + 1, gg)
        else:
            arr.append(0)
            shit(n + 1, arr)


shit(0, [])
print(int(ans))

#!/usr/bin/env python3

from itertools import product
from operator import mul
from functools import reduce

n = input().strip()
c0 = n.count('0')
cc = [n.count(str(i)) for i in range(10)]
cc = [c for c in cc if c > 0]

facs = [1]
for i in range(1, 20):
	facs.append(facs[-1] * i)

def prod(p):
	return reduce(mul, p, 1)

def getC(p):
	return facs[sum(p)] // prod(facs[pp] for pp in p)

def getcount(ct, a0=False):
	its = [list(range(1 - int(a0), ct[0] + 1))] + [list(range(1, cti + 1)) for cti in ct[1:]]
	return sum(getC(p) for p in product(*its))

if c0 == 0:
	res = getcount(cc)
elif c0 == 1:
	ccr = list(cc)
	del ccr[0]
	res = getcount(cc) - getcount(ccr)
else:
	ccr = list(cc)
	ccr[0] -= 1
	res = getcount(cc) - getcount(ccr, True)

print (res)


from itertools import product
from math import factorial
from operator import mul
from functools import reduce

seen = input()

counts = [[0] for digit in range(10)]

for digit in map(int, seen):
    counts[digit].append(counts[digit][-1] + 1)

for digit in range(10):
    if len(counts[digit]) > 1:
        counts[digit].pop(0)

answer = 0

for count in product(*counts):
    answer += factorial(sum(count)) // reduce(mul, (factorial(count[digit]) for digit in range(10)))
    
    if count[0] > 0:
        count = list(count)
        count[0] -= 1
        answer -= factorial(sum(count)) // reduce(mul, (factorial(count[digit]) for digit in range(10)))
        
print(answer)