import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); BigInteger a = BigInteger.valueOf(sc.nextInt()); BigInteger b = BigInteger.valueOf(sc.nextInt()); BigInteger c = BigInteger.valueOf(sc.nextInt()); BigInteger d = BigInteger.valueOf(sc.nextInt()); System.out.println(a.multiply(b).multiply(c).remainder(d)); sc.close(); } }