import itertools N = int(input()) words = [] for _ in range(N): word = input() words.append(word) str_list = [] for c in itertools.permutations(words): s = ''.join(c) str_list.append(s) ans = len(set(str_list)) print(ans)