// ~~ icebear love attttttt ~~
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
template<class T>
bool minimize(T &a, const T &b) {
if (a > b) return a = b, true;
return false;
}
template<class T>
bool maximize(T &a, const T &b) {
if (a < b) return a = b, true;
return false;
}
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define MASK(i) (1LL << (i))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "icebearat"
const int MOD = 1e9 + 7;
const int inf = 1e9 + 27092008;
const ll INF = 1e18 + 27092008;
const int N = 100 + 5;
int k, p, dp[N][N];
vector<int> digit;
string L, R;
int DP(int pos, int cnt, bool start, bool smaller) {
if (cnt > k) return 0;
if (pos < 0) return cnt <= k;
int ret = dp[pos][cnt];
if (smaller && ~ret) return ret;
ret = 0;
int limit = (smaller ? 9 : digit[pos]);
FOR(i, 0, limit) {
bool newStart = (start | (i > 0));
int newCnt = cnt + (i == p && newStart);
ret = (ret + DP(pos - 1, newCnt, newStart, smaller | (i < limit))) % MOD;
}
if (smaller) dp[pos][cnt] = ret;
return ret;
}
bool check(string &x) {
int cnt = 0;
for(char c : x) if (c - '0' == p)
cnt++;
return cnt <= k;
}
int f(string &x) {
digit.clear();
for(char c : x) digit.pb(c - '0');
reverse(all(digit));
return DP((int)digit.size() - 1, 0, 0, 0);
}
void init(void) {
cin >> L >> R >> k >> p;
}
void process(void) {
memset(dp, -1, sizeof dp);
cout << (f(R) - f(L) + check(L) + MOD) % MOD;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int tc = 1;
// cin >> tc;
while(tc--) {
init();
process();
}
return 0;
}
Ly8gfn4g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