#include #include #include #include #include #include #include using namespace std; #define diff(x,y) ((x > y) ? (x - y) : (y - x)) #define us(x) ((x > 0) ? x : x * -1) #define change(x) (x ? false : true) #define lli long long int int main() { lli a, b, c, d; cin >> a >> b >> c >> d; cout << a * b * c % d << endl; return 0; }