#include <stdio.h>
typedef long long LL;
inline LL mult_mod(LL a, LL b, LL m){ // a * b % m
a = (a % m + m) % m;
b = (b % m + m) % m;
LL ans = a * b - (LL)((long double) a * b / m + 0.5) * m;
return ans < 0? ans + m : ans;
}
int main(){
LL x, y, m;
scanf("%lld%lld%lld", &x, &y, &m);
printf("%lld\n", mult_mod(x, y, m));
return 0;
}