n,m=gets.split.map &:to_i if n>=m puts 0 else s=1%m for i in 1..n s=(s*i)%m end puts s end