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