#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAX_A 50
#define MAX_C 750
#define MAX_D 50
#define r(A) A.begin(),A.end()
#define sz(x) (int)(x).size()
int dp[MAX_A][MAX_D][MAX_C][2];
int f[MAX_A];
int c, d, n;
string a, b, s, rs;
string dec(string a) {
for (int i = sz(a) - 1;; --i) {
if (a[i] == '0') a[i] = '9';
else { a[i]--; break; }
}
if (sz(a) > 1 && a[0] == '0') return a.substr(1);
return a;
}
int calc(string a) {
memset(dp, 0, sizeof(dp));
memset(f, 0, sizeof(f));
dp[0][0][0][0] = 1;
n = a.size() / 2;
s = a.substr(0, n);
rs = a.substr(n);
reverse(r(s));
if (s < rs) {
reverse(r(s));
dec(s);
}
else {
reverse(r(s));
}
int z = 1;
for (int i = 0; i < n; i++) {
f[i] += z;
z = z * 10 % c;
}
for (int i = 0; i < n; i++) {
f[n - 1 - i] += z;
z = z * 10 % c;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < c; j++) {
for (int k = 0; k <= d; k++) {
for (int l = 0; l < 2; l++) {
for (int m = 0; m < 10; m++) {
int I = i + 1, J = (j + f[i] * m) % c, K = k + m, L = l;
if (m < s[i] - '0') L = 1;
if (!l && m > s[i] - '0') continue;
dp[I][J][K][L] += dp[i][j][k][l];
dp[I][J][K][L] = (dp[I][J][K][L] + 1000000) % 10000;
}
}
}
}
}
int sum = 0;
for (int i = 0; i <= d; i++) {
for (int j = 0; j < 2; j++) {
if (i * 2 == d) {
sum += dp[n][0][i][j];
sum %= 10000;
}
}
}
return sum;
}
int main() {
cin >> a >> b >> c >> d;
cout << (calc(b) - calc(a) + 1000000) % 10000 << endl;
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0cmluZz4KI2luY2x1ZGU8YWxnb3JpdGhtPgojaW5jbHVkZTxjc3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBNQVhfQSA1MAojZGVmaW5lIE1B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