#coding: utf-8 #yuki373 a,b,d,c=map(int,raw_input().split()) res=(a%d)*(b%d)*(c%d) print res