#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
inline int pow(int n, int k, int mod);
int n, m, k, x;
int Main() {
#ifndef LOCAL
freopen("CircleNOIP2013.in", "r", stdin);
freopen("CircleNOIP2013.out", "w", stdout);
#endif
scanf("%d%d%d%d", &n, &m, &k, &x);
m = (m * pow(10, k, n)) % n;
x = (x + m) % n;
printf("%d", x);
return 0;
}
int Main_ = Main();
int main() { ;}
inline int pow(int n, int k, int mod) {
register int ret = 1;
while(k) {
if(k & 1) ret = (ret * n) % mod;
n = (n * n) % mod;
k >>= 1;
}
return ret;
}