using System; using System.Collections; using System.Linq; class Program { static void Main() { int[] xs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); Console.WriteLine(((xs[0] % xs[3]) * (xs[1] % xs[3]) * (xs[2] % xs[3])) % xs[3]); } }