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