import java.util.Scanner; public class Main { public static void main(String[] args) { //入力文字をの読み取り Scanner sc = new Scanner(System.in); //1文字目 long a = sc.nextInt(); //2文字目 long b = sc.nextInt(); //3文字目 long c = sc.nextInt(); //4文字目 long d = sc.nextInt(); //計算 long result = a*b; result = result*c; result = result%d; //出力 System.out.println(result); } }