#include "stdio.h" int main(){ int x,y,z,a,m; scanf("%d %d %d %d",&x,&y,&z,&m); a=x*y*z; printf("%d",a%m); return 0; }