import itertools as it
s = map(int, input(">>>").split(","))
s = set(s)
if len(s) < 3:
print("不足三位数!")
else:
res = it.permutations(s, 3)
res = [''.join(map(str, i)) for i in res if i[0] != 0]
res.sort()
print(' '.join(map(str, res)))
print(f"共{len(res)}个")