package me.yukicoder.lv1_5; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class No0373 { public static void main(String[] args) { try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { String[] str = br.readLine().split(" "); long ans = (Long.parseLong(str[0]) * Long.parseLong(str[1]) * Long.parseLong(str[2])) % Long.parseLong(str[3]); System.out.println(ans); } catch (IOException e) { e.printStackTrace(); } } }