main = getLine >>= print . f . map read . words where f xs = (foldr (*) 1 (init xs)) `mod` last xs