#include using namespace std; int main(){ long long a,b,c,d; cin >> a >> b >> c >> d; a=a%d,b=b%d,c=c%d; cout << (long long) a*b*c << endl; }