main = getLine >>= print . (\ls -> product (init ls) `mod` last ls) . map read . words