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