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