import collections N = int(input()) C = collections.Counter(list(input())) hachi = set() if N>4: N=3 for i in range(10**(N-1),10**N): if not (collections.Counter(list(str(i))) - C): hachi.add(i%40) print(len(hachi))