#include #include using namespace std; int main() { long a, b, c, d, ans; cin >> a >> b >> c >>d; ans = ((a%d)*(b%d)*(c%d)) % d; //cout << ans << endl; printf("%d\n", ans); return 0; }