from itertools import permutations
print sum(all(i != j for i, j in enumerate(p))
          for p in permutations(range(5)))