using System.Numerics; public class Program { public static void Main() { //int num = int.Parse(Console.ReadLine() ?? string.Empty); string[] str = (Console.ReadLine() ?? string.Empty).Trim().Split(' '); //string str = Console.ReadLine() ?? string.Empty; int a = int.Parse(str[0]); int b = int.Parse(str[1]); int c = int.Parse(str[2]); int d = int.Parse(str[3]); long ab = ((long)a * (long)b); BigInteger abc = ab * (BigInteger)c; BigInteger ans = abc % (BigInteger)d; Console.WriteLine(ans); } }