let A, B, C, D = let t = stdin.ReadLine().Split() |> Array.map int |> Array.map bigint t.[0], t.[1], t.[2], t.[3] A * B * C % D |> printfn "%A"