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