#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const int md = 1000000007;

inline int mul(int a, int b)
{
	return (int)((long long)a * b);
}
inline void sum(int &a, int b)
{
	a += b;
	if (a >= md) a -= md;
}

vector<int> decim;

int opt(int *a, int size, int d)
{
	for (int i = 1; i < size; i += 2) {
		if (a[i] < d) {
			while (!a[--i]);
			--a[i];
			if (i == 0 && a[i] == 0) return 0;
			++i;
			while (i < size) {
				a[i] = 9;
				++i;
			}
			return opt(a, size, d);
		}
	}
	return 1;
}

int amount(int *a, int n, int size, int m, int d, int ind)
{
	if (!a[0]) return 0;
	if (!opt(a, size, d)) return 0;
	pair<vector<vector<int> >, vector<vector<int> > > amt(vector<vector<int> >(n, vector<int>(m)), vector<vector<int> >(n, vector<int>(m)));
	if (a[0] != d) amt.second[0][(a[0] * decim[0]) % m] = 1;
	for (int i = 1; i < a[0]; ++i) if (i != d) ++amt.first[0][(i * decim[0]) % m];
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			for (int k = 0; k < 10; ++k) if (k != d) sum(amt.first[i][(j + k * decim[i * 2]) % m], amt.first[i - 1][j]);
			for (int k = 0; k <= a[i * 2]; ++k) if (k != d) sum(amt.first[i][(j + k * decim[i * 2]) % m], amt.second[i - 1][j]);
			if (a[2 * i] != d) sum(amt.second[i][(j + a[i * 2] * decim[i * 2]) % m], amt.second[i - 1][j]);
		}
	}
	// for (int i = 0; i < n; ++i) {
	// 	for (int j = 0; j < m; ++j) printf("%d %d %d %d\n", i, j, amt.first[i][j], amt.second[i][j]);
	// 	printf("\n");
	// }
	// printf("\n");
	return (amt.first[n - 1][ind] + amt.second[n - 1][ind]) % md;
}

void minusone(int *a, int size)
{
	int i = size - 1;
	while (!a[i]) --i;
	--a[i];
	++i;
	while (i < size) {
		a[i] = 9;
		++i;
	}
}

int main()
{
	int m, d, a[2000], b[2000];
	scanf("%d%d", &m, &d);
	char buf[2001];
	scanf("%s", buf);
	int n = strlen(buf);
	for (int i = 0; i < n; ++i) a[i] = buf[i] - '0';
	scanf("%s", buf);
	for (int i = 0; i < n; ++i) b[i] = buf[i] - '0';
	decim.resize(n);
	decim[n - 1] = 1 % m;
	for (int i = n - 2; i >= 0; --i) decim[i] = decim[i + 1] * 10 % m;
	int ind = 0;
	for (int i = 1; i < n; i += 2) ind += decim[i] * d;
	ind = - ind;
	ind = (ind % m + m) % m;
	minusone(a, n);
	printf("%d\n", amount(b, n / 2 + (n & 1), n, m, d, ind) - amount(a, n / 2 + (n & 1), n, m, d, ind));
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const int md = 1000000007;

inline int mul(int a, int b)
{
	return (int)((long long)a * b);
}
inline void sum(int &a, int b)
{
	a += b;
	if (a >= md) a -= md;
}

vector<int> decim;

int opt(int *a, int size, int d)
{
	for (int i = 1; i < size; i += 2) {
		if (a[i] < d) {
			while (!a[--i]);
			--a[i];
			if (i == 0 && a[i] == 0) return 0;
			++i;
			while (i < size) {
				a[i] = 9;
				++i;
			}
			return opt(a, size, d);
		}
	}
	return 1;
}

int amount(int *a, int n, int size, int m, int d, int ind)
{
	if (!a[0]) return 0;
	if (!opt(a, size, d)) return 0;
	pair<vector<vector<int> >, vector<vector<int> > > amt(vector<vector<int> >(n, vector<int>(m)), vector<vector<int> >(n, vector<int>(m)));
	if (a[0] != d) amt.second[0][(a[0] * decim[0]) % m] = 1;
	for (int i = 1; i < a[0]; ++i) if (i != d) ++amt.first[0][(i * decim[0]) % m];
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			for (int k = 0; k < 10; ++k) if (k != d) sum(amt.first[i][(j + k * decim[i * 2]) % m], amt.first[i - 1][j]);
			for (int k = 0; k < a[i * 2]; ++k) if (k != d) sum(amt.first[i][(j + k * decim[i * 2]) % m], amt.second[i - 1][j]);
			if (a[2 * i] != d) sum(amt.second[i][(j + a[i * 2] * decim[i * 2]) % m], amt.second[i - 1][j]);
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) printf("%d %d %d %d\n", i, j, amt.first[i][j], amt.second[i][j]);
		printf("\n");
	}
	printf("\n");
	return (amt.first[n - 1][ind] + amt.second[n - 1][ind]) % md;
}

void minusone(int *a, int size)
{
	int i = size - i;
	while (i >= 0 && !a[i]) --i;
	--a[i];
	++i;
	while (i < size) {
		a[i] = 9;
		++i;
	}
}

int main()
{
	int m, d, a[2000], b[2000];
	scanf("%d%d", &m, &d);
	char buf[2001];
	scanf("%s", buf);
	int n = strlen(buf);
	for (int i = 0; i < n; ++i) a[i] = buf[i] - '0';
	scanf("%s", buf);
	for (int i = 0; i < n; ++i) b[i] = buf[i] - '0';
	decim.resize(n);
	decim[n - 1] = 1 % m;
	for (int i = n - 2; i >= 0; --i) decim[i] = decim[i + 1] * 10 % m;
	int ind = 0;
	for (int i = 1; i < n; i += 2) ind += decim[i] * d;
	ind = - ind;
	ind = (ind % m + m) % m;
	minusone(a, n);
	printf("%d\n", amount(b, n / 2 + (n & 1), n, m, d, ind) - amount(a, n / 2 + (n & 1), n, m, d, ind));
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const int md = 1000000007;

void sum(int &a, int b)
{
	a += b;
	if (a > md) a -= md;
}

vector<int> decim;

int solve(int *a, int n, int m, int d)
{
	vector<vector<int> > dp(n, vector<int>(m));
	vector<int> pr(n);
	for (int i = 0; i < a[0]; ++i) if (i != d) ++dp[0][i * decim[0] % m];
	pr[0] = a[0] * decim[0] % m;
	for (int i = 1; i < n; ++i) {
		if (i & 1) {
			for (int j = 0; j < m; ++j) sum(dp[i][(j + d * decim[i]) % m], dp[i - 1][j]);
			if (pr[i - 1] != -1) {
				if (d < a[i]) sum(dp[i][(pr[i - 1] + d * decim[i]) % m], 1);
				if (a[i] == d) pr[i] = (pr[i - 1] + d * decim[i]) % m;
				else pr[i] = -1;
			}
			else pr[i] = -1;
		}
		else {
			for (int j = 0; j < m; ++j) {
				for (int k = 0; k < 10; ++k) if (k != d) sum(dp[i][(j + k * decim[i]) % m], dp[i - 1][j]);
			}
			if (pr[i - 1] != -1) {
				for (int k = 0; k < a[i]; ++k) if (k != d) sum(dp[i][(pr[i - 1] + k * decim[i]) % m], 1);
				if (a[i] != d) pr[i] = (pr[i - 1] + a[i] * decim[i]) % m;
				else pr[i] = -1;
			}
			else pr[i] = -1;
		}
	}
	return dp[n - 1][0] + (pr[n - 1] == 0);
}
bool check(int *a, int n, int m, int d)
{
	int res = 0;
	for (int i = 0; i < n; ++i) {
		if (i & 1 && a[i] != d) return 0;
		res = (res + a[i] * decim[i]) % m;
	}
	return !res;
}

int main()
{
	int m, d;
	scanf("%d%d", &m, &d);
	int a[2000], b[2000];
	char buf[2001];
	scanf("%s", buf);
	int n = strlen(buf);
	for (int i = 0; i < n; ++i) a[i] = buf[i] - '0';
	scanf("%s", buf);
	for (int i = 0; i < n; ++i) b[i] = buf[i] - '0';

	decim.resize(n);
	decim[n - 1] = 1 % m;
	for (int i = n - 2; i >= 0; --i) decim[i] = decim[i + 1] * 10 % m;

	printf("%d\n", solve(b, n, m, d) - solve(a, n, m, d) + check(a, n, m, d));
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const int md = 1000000007;

inline int mul(int a, int b)
{
	return (int)((long long)a * b);
}
inline void sum(int &a, int b)
{
	a += b;
	if (a >= md) a -= md;
}

vector<int> decim;

int opt(int *a, int size, int d)
{
	for (int i = 1; i < size; i += 2) {
		if (a[i] < d) {
			while (!a[--i]);
			--a[i];
			if (i == 0 && a[i] == 0) return 0;
			++i;
			while (i < size) {
				a[i] = 9;
				++i;
			}
			return opt(a, size, d);
		}
	}
	return 1;
}

int amount(int *a, int n, int size, int m, int d, int ind)
{
	if (!a[0]) return 0;
	if (!opt(a, size, d)) return 0;
	pair<vector<vector<int> >, vector<vector<int> > > amt(vector<vector<int> >(n, vector<int>(m)), vector<vector<int> >(n, vector<int>(m)));
	if (a[0] != d) amt.second[0][(a[0] * decim[0]) % m] = 1;
	for (int i = 1; i < a[0]; ++i) if (i != d) ++amt.first[0][(i * decim[0]) % m];
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			for (int k = 0; k < 10; ++k) if (k != d) sum(amt.first[i][(j + k * decim[i * 2]) % m], amt.first[i - 1][j]);
			for (int k = 0; k < a[i * 2]; ++k) if (k != d) sum(amt.first[i][(j + k * decim[i * 2]) % m], amt.second[i - 1][j]);
			if (a[2 * i] != d) sum(amt.second[i][(j + a[i * 2] * decim[i * 2]) % m], amt.second[i - 1][j]);
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) printf("%d %d %d %d\n", i, j, amt.first[i][j], amt.second[i][j]);
		printf("\n");
	}
	printf("\n");
	return (amt.first[n - 1][ind] + amt.second[n - 1][ind]) % md;
}

void minusone(int *a, int size)
{
	int i = size - i;
	while (i >= 0 && !a[i]) --i;
	if (i >= 0) --a[i];
	++i;
	while (i < size) {
		a[i] = 9;
		++i;
	}
}

int main()
{
	int m, d, a[2000], b[2000];
	scanf("%d%d", &m, &d);
	char buf[2001];
	scanf("%s", buf);
	int n = strlen(buf);
	for (int i = 0; i < n; ++i) a[i] = buf[i] - '0';
	scanf("%s", buf);
	for (int i = 0; i < n; ++i) b[i] = buf[i] - '0';
	decim.resize(n);
	decim[n - 1] = 1 % m;
	for (int i = n - 2; i >= 0; --i) decim[i] = decim[i + 1] * 10 % m;
	int ind = 0;
	for (int i = 1; i < n; i += 2) ind += decim[i] * d;
	ind = - ind;
	ind = (ind % m + m) % m;
	minusone(a, n);
	printf("%d\n", amount(b, n / 2 + (n & 1), n, m, d, ind) - amount(a, n / 2 + (n & 1), n, m, d, ind));
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const int md = 1000000007;

inline int mul(int a, int b)
{
	return (int)((long long)a * b);
}
inline void sum(int &a, int b)
{
	a += b;
	if (a >= md) a -= md;
}

vector<int> decim;

int opt(int *a, int size, int d)
{
	for (int i = 1; i < size; i += 2) {
		if (a[i] < d) {
			while (!a[--i]);
			--a[i];
			if (i == 0 && a[i] == 0) return 0;
			++i;
			while (i < size) {
				a[i] = 9;
				++i;
			}
			return opt(a, size, d);
		}
	}
	return 1;
}

int amount(int *a, int n, int size, int m, int d, int ind)
{
	if (!a[0]) return 0;
	if (!opt(a, size, d)) return 0;
	pair<vector<vector<int> >, vector<vector<int> > > amt(vector<vector<int> >(n, vector<int>(m)), vector<vector<int> >(n, vector<int>(m)));
	if (a[0] != d) amt.second[0][(a[0] * decim[0]) % m] = 1;
	for (int i = 1; i < a[0]; ++i) if (i != d) ++amt.first[0][(i * decim[0]) % m];
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			for (int k = 0; k < 10; ++k) if (k != d) sum(amt.first[i][(j + k * decim[i * 2]) % m], amt.first[i - 1][j]);
			for (int k = 0; k < a[i * 2]; ++k) if (k != d) sum(amt.first[i][(j + k * decim[i * 2]) % m], amt.second[i - 1][j]);
			if (a[2 * i] != d) sum(amt.second[i][(j + a[i * 2] * decim[i * 2]) % m], amt.second[i - 1][j]);
		}
	}
	// for (int i = 0; i < n; ++i) {
	// 	for (int j = 0; j < m; ++j) printf("%d %d %d %d\n", i, j, amt.first[i][j], amt.second[i][j]);
	// 	printf("\n");
	// }
	// printf("\n");
	return (amt.first[n - 1][ind] + amt.second[n - 1][ind]) % md;
}

void minusone(int *a, int size)
{
	int i = size - 1;
	while (!a[i]) --i;
	--a[i];
	++i;
	while (i < size) {
		a[i] = 9;
		++i;
	}
}

int main()
{
	int m, d, a[2000], b[2000];
	scanf("%d%d", &m, &d);
	char buf[2001];
	scanf("%s", buf);
	int n = strlen(buf);
	for (int i = 0; i < n; ++i) a[i] = buf[i] - '0';
	scanf("%s", buf);
	for (int i = 0; i < n; ++i) b[i] = buf[i] - '0';
	decim.resize(n);
	decim[n - 1] = 1 % m;
	for (int i = n - 2; i >= 0; --i) decim[i] = decim[i + 1] * 10 % m;
	int ind = 0;
	for (int i = 1; i < n; i += 2) ind += decim[i] * d;
	ind = - ind;
	ind = (ind % m + m) % m;
	minusone(a, n);
	printf("%d\n", amount(b, n / 2 + (n & 1), n, m, d, ind) - amount(a, n / 2 + (n & 1), n, m, d, ind));
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const int md = 1000000007;

void sum(int &a, int b)
{
	a += b;
	if (a > md) a -= md;
}

vector<int> decim;

int solve(int *a, int n, int m, int d)
{
	vector<vector<int> > dp(n, vector<int>(m));
	vector<int> pr(n);
	for (int i = 0; i < a[0]; ++i) if (i != d) ++dp[0][i * decim[0] % m];
	pr[0] = a[0] != d ? a[0] * decim[0] % m : -1;
	for (int i = 1; i < n; ++i) {
		if (i & 1) {
			for (int j = 0; j < m; ++j) sum(dp[i][(j + d * decim[i]) % m], dp[i - 1][j]);
			if (pr[i - 1] != -1) {
				if (d < a[i]) sum(dp[i][(pr[i - 1] + d * decim[i]) % m], 1);
				if (a[i] == d) pr[i] = (pr[i - 1] + d * decim[i]) % m;
				else pr[i] = -1;
			}
			else pr[i] = -1;
		}
		else {
			for (int j = 0; j < m; ++j) {
				for (int k = 0; k < 10; ++k) if (k != d) sum(dp[i][(j + k * decim[i]) % m], dp[i - 1][j]);
			}
			if (pr[i - 1] != -1) {
				for (int k = 0; k < a[i]; ++k) if (k != d) sum(dp[i][(pr[i - 1] + k * decim[i]) % m], 1);
				if (a[i] != d) pr[i] = (pr[i - 1] + a[i] * decim[i]) % m;
				else pr[i] = -1;
			}
			else pr[i] = -1;
		}
	}
	return dp[n - 1][0] + (pr[n - 1] == 0);
}
bool check(int *a, int n, int m, int d)
{
	int res = 0;
	for (int i = 0; i < n; ++i) {
		if (i & 1 && a[i] != d) return 0;
		res = (res + a[i] * decim[i]) % m;
	}
	return !res;
}

int main()
{
	int m, d;
	scanf("%d%d", &m, &d);
	int a[2000], b[2000];
	char buf[2001];
	scanf("%s", buf);
	int n = strlen(buf);
	for (int i = 0; i < n; ++i) a[i] = buf[i] - '0';
	scanf("%s", buf);
	for (int i = 0; i < n; ++i) b[i] = buf[i] - '0';

	decim.resize(n);
	decim[n - 1] = 1 % m;
	for (int i = n - 2; i >= 0; --i) decim[i] = decim[i + 1] * 10 % m;

	printf("%d\n", solve(b, n, m, d) - solve(a, n, m, d) + check(a, n, m, d));
	return 0;
}


#include <iostream>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

const int md = 1000000007;

int n;
int m, d;
int a[2000], b[2000];
vector<int> decimal;
vector<vector<int> > digits;
vector<vector<int> > amt;

inline int sum(int a, int b)
{
	a += b;
	return a < md ? a : a - md;
}

void get(int x)
{
	vector<int> current(m);
	int sz = digits[x].size();
	int decim = decimal[n - x * 2 - 1];
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < sz; ++j) {
			int ind = (i + digits[x][j] * decim) % m;
			current[ind] = sum(amt[x - 1][i], current[ind]);
		}
	}
	for (int i = 0; i < m; ++i) amt[x][i] = current[i];
}

int main()
{
	scanf("%d%d", &m, &d);
	char buf[2001];
	scanf("%s", buf);
	n = strlen(buf);
	for (int i = 0; i < n; ++i) a[i] = buf[n - i - 1] - '0';
	scanf("%s", buf);
	for (int i = 0; i < n; ++i) b[i] = buf[n - i - 1] - '0';

	decimal.resize(n);
	decimal[0] = 1 % m;
	for (int i = 1; i < n; ++i) decimal[i] = 10 * decimal[i - 1] % m;

	int put = n / 2 + (n & 1);

	digits.resize(put);
	int i;
	for (i = n - 1; i >= 0 && a[i] == b[i]; --i) {
		int k = (n - i - 1) >> 1;
		if ((n - i - 1) & 1 && a[i] != d) {
			printf("0\n");
			return 0;
		}
		if (!((n - i - 1) & 1)) {
			if (a[i] == d) {
				printf("0\n");
				return 0;
			}
			digits[k].push_back(a[i]);
		}
	}
	if (i >= 0) {
		if ((n - i - 1) & 1) {
			if ((a[i] > d || b[i] < d)) {
				printf("0\n");
				return 0;
			}
			--i;
		}
		int k = (n - i - 1) >> 1;
		for (int j = a[i] + (i > 0 && (a[i - 1] > d || b[i - 1] < d)); j <= b[i]; ++j) if (j != d) digits[k].push_back(j);
		i -= 2;
		while (i >= 0) {
			k = (n - i - 1) >> 1;
			digits[k].resize(9);
			for (int j = 0; j <= 9; ++j) {
				if (j != d) digits[k][j > d ? j - 1 : j] = j;
			}
			i -= 2;
		}
	}

	amt.resize(put, vector<int>(m));
	for (int i = 0; i < digits[0].size(); ++i) ++amt[0][digits[0][i] * decimal[n - 1] % m];
	for (int i = 1; i < put; ++i) get(i);

	int evenres = 0;
	for (int i = n - 2; i >= 0; i -= 2) evenres += d * decimal[i] % m;
	evenres = m - evenres;
	evenres = ((evenres % m) + m) % m;
	printf("%d\n", amt[put - 1][evenres]);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;

int m, d, n;
string lo, hi;
int dp[2000][2][2][2][2][2000];

int solve(int idx = 0, int put = 0, int par = 0, int bot = 0, int top = 0, int rem = 0) {
	if (idx == n)
		return (put && rem==0);

	if (dp[idx][put][par][bot][top][rem] != -1) return dp[idx][put][par][bot][top][rem];

	int ans = 0;
	int mn = bot ? 0 : lo[idx]-'0';
	int mx = top ? 9 : hi[idx]-'0';
	if (!idx || !put) {
		for (int i = mn; i <= mx; ++i) {
			if (i==d) continue;
			ans = (ans + solve(idx + 1, (i!=0), 0, bot | (i!=mn), top | (i!=mx), ((rem*10) % m + i) % m)) % MOD;
		}
	} else {
		for (int i = mn; i <= mx; ++i) {
			if (par == (i!=d))
				ans = (ans + solve(idx + 1, put, !par, bot | (i!=mn), top | (i!=mx), ((rem*10) % m + i) % m)) % MOD;
		}
	}

	return dp[idx][put][par][bot][top][rem] = ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	cin >> m >> d;
	cin >> lo >> hi;
	n = lo.size();
	for (int i = 0; i < n; ++i)
	for (int j = 0; j < 2; ++j)
	for (int k = 0; k < 2; ++k)
	for (int l = 0; l < 2; ++l)
	for (int o = 0; o < 2; ++o)
	for (int p = 0; p < m; ++p)
	dp[i][j][k][l][o][p] = -1;
	cout << solve() << "\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;

int timer, m, d;
string lo, hi;
int dp[2000][2][2][2][2][2000];

int solve(int idx = 0, bool bot = 0, bool top = 0, bool put = 0, bool par = 0, int rem = 0) {
	if (idx == (int)lo.size()) {
		return (put and !rem);
	}
	if (dp[idx][bot][top][put][par][rem] != -1)
		return dp[idx][bot][top][put][par][rem];

	int ans = 0;
	int mn = bot ? 0 : lo[idx]-'0';
	int mx = top ? 9 : hi[idx]-'0';
	if (put==0) {
		for (int i = mn; i <= mx; ++i) {
			if (i == d) continue;
			ans = (ans+solve(idx + 1, bot | (i != mn), top | (i != mx), (i != 0), 1, (rem*10%m+i)%m))%mod;
		}
	} else {
		for (int i = mn; i <= mx; ++i) {
			if ((par and i==d) or (!par and i!=d))
				ans = (ans+solve(idx + 1, bot | (i != mn), top | (i != mx), 1, 1-par, (rem*10%m+i)%m))%mod;
		}
	}
	return dp[idx][bot][top][put][par][rem] = ans;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0);
	memset(dp, -1, sizeof(dp));
	cin >> m >> d;
	cin >> lo >> hi;
	timer++;
	cout << solve() << "\n";
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;

int m, d, n;
string lo, hi;
int dp[2000][2][2][2][2][2][2000];

int solve(int idx = 0, int put = 0, int par = 0, int can = 0, int bot = 0, int top = 0, int rem = 0) {
	if (idx == n)
		return (put && rem==0 && can);

	if (dp[idx][put][par][can][bot][top][rem] != -1) return dp[idx][put][par][can][bot][top][rem];

	int ans = 0;
	int mn = bot ? 0 : lo[idx]-'0';
	int mx = top ? 9 : hi[idx]-'0';
	if (!idx || !put) {
		for (int i = mn; i <= mx; ++i) {
			ans = (ans + solve(idx + 1, (i != 0), 0, (i != d), bot | (i!=mn), top | (i!=mx), ((rem*10) % m + i) % m)) % MOD;
		}
	} else {
		for (int i = mn; i <= mx; ++i) {
			ans = (ans + solve(idx + 1, put, !par, can & ((par & (i!=d)) | (!par & (i==d))), bot | (i!=mn), top | (i!=mx), ((rem*10) % m + i) % m)) % MOD;
		}
	}

	return dp[idx][put][par][can][bot][top][rem] = ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	memset(dp, -1, sizeof(dp));
	cin >> m >> d;
	cin >> lo >> hi;
	n = lo.size();
	cout << solve() << "\n";
	return 0;
}


#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;

int m, d, n;
string lo, hi;
int dp[2000][2][2][2][2][2000];

int solve(int idx = 0, int put = 0, int par = 0, int bot = 0, int top = 0, int rem = 0) {
	if (idx == n)
		return (put && rem==0);

	if (dp[idx][put][par][bot][top][rem] != -1) return dp[idx][put][par][bot][top][rem];

	int ans = 0;
	int mn = bot ? 0 : lo[idx]-'0';
	int mx = top ? 9 : hi[idx]-'0';
	if (!idx || !put) {
		for (int i = mn; i <= mx; ++i) {
			if (i==d) continue;
			ans = (ans + solve(idx + 1, (i!=0), 0, bot | (i!=mn), top | (i!=mx), ((rem*10) % m + i) % m)) % MOD;
		}
	} else {
		for (int i = mn; i <= mx; ++i) {
			if (par == (i!=d))
				ans = (ans + solve(idx + 1, put, !par, bot | (i!=mn), top | (i!=mx), ((rem*10) % m + i) % m)) % MOD;
		}
	}

	return dp[idx][put][par][bot][top][rem] = ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	cin >> m >> d;
	cin >> lo >> hi;
	n = lo.size();
	for (int i = 0; i < n; ++i)
	for (int j = 0; j < 2; ++j)
	for (int k = 0; k < 2; ++k)
	for (int l = 0; l < 2; ++l)
	for (int o = 0; o < 2; ++o)
	for (int p = 0; p < m; ++p)
	dp[i][j][k][l][o][p] = -1;
	cout << solve() << "\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;

int m, d, n;
string lo, hi;
bool seen[2000][2][2][2][2][2][2000];
int dp[2000][2][2][2][2][2][2000];

int solve(int idx = 0, int put = 0, int par = 0, int can = 0, int bot = 0, int top = 0, int rem = 0) {
	if (idx == n)
		return (put && rem==0 && can);

	if (seen[idx][put][par][can][bot][top][rem]) return dp[idx][put][par][can][bot][top][rem];
	seen[idx][put][par][can][bot][top][rem] = true;

	int ans = 0;
	int mn = bot ? 0 : lo[idx]-'0';
	int mx = top ? 9 : hi[idx]-'0';
	if (!idx || !put) {
		for (int i = mn; i <= mx; ++i) {
			ans = (ans + solve(idx + 1, (i != 0), 0, (i != d), bot | (i!=mn), top | (i!=mx), ((rem*10) % m + i) % m)) % MOD;
		}
	} else {
		for (int i = mn; i <= mx; ++i) {
			ans = (ans + solve(idx + 1, put, !par, can & ((par & (i!=d)) | (!par & (i==d))), bot | (i!=mn), top | (i!=mx), ((rem*10) % m + i) % m)) % MOD;
		}
	}

	return dp[idx][put][par][can][bot][top][rem] = ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	cin >> m >> d;
	cin >> lo >> hi;
	n = lo.size();
	cout << solve() << "\n";
	return 0;
}


#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;

int m, d, n;
string lo, hi;
int dp[2000][2][2][2][2][2000];

int solve(int idx = 0, int put = 0, int par = 0, int bot = 0, int top = 0, int rem = 0) {
	if (idx == n)
		return (put && rem==0);

	if (dp[idx][put][par][bot][top][rem] != -1) return dp[idx][put][par][bot][top][rem];

	int ans = 0;
	int mn = bot ? 0 : lo[idx]-'0';
	int mx = top ? 9 : hi[idx]-'0';
	if (!idx || !put) {
		for (int i = mn; i <= mx; ++i) {
			if (i==d) continue;
			ans = (ans + solve(idx + 1, (i!=0), 0, bot | (i!=mn), top | (i!=mx), ((rem*10) % m + i) % m)) % MOD;
		}
	} else {
		for (int i = mn; i <= mx; ++i) {
			if (par == (i!=d))
				ans = (ans + solve(idx + 1, put, !par, bot | (i!=mn), top | (i!=mx), ((rem*10) % m + i) % m)) % MOD;
		}
	}

	return dp[idx][put][par][bot][top][rem] = ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	cin >> m >> d;
	cin >> lo >> hi;
	n = lo.size();
	memset(dp, -1, sizeof(dp));
	cout << solve() << "\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;

int timer, m, d;
string lo, hi;
ll dp[2001][2][2][2][2][2000];
ll seen[2001][2][2][2][2][2000];

ll solve(int idx = 0, bool bot = 0, bool top = 0, bool put = 0, bool par = 0, int rem = 0) {
	if (idx == (int)lo.size()) {
		return (put and !rem);
	}
	if (seen[idx][bot][top][put][par][rem] == timer)
		return dp[idx][bot][top][put][par][rem];
	seen[idx][bot][top][put][par][rem] = timer;
	ll ans = 0;
	int mn = bot ? 0 : lo[idx]-'0';
	int mx = top ? 9 : hi[idx]-'0';
	if (put==0) {
		for (int i = mn; i <= mx; ++i) {
			if (i == d) continue;
			ans = (ans+solve(idx + 1, bot | (i != mn), top | (i != mx), (i != 0), 1, (rem*10%m+i)%m))%mod;
		}
	} else {
		for (int i = mn; i <= mx; ++i) {
			if ((par and i==d) or (!par and i!=d))
				ans = (ans+solve(idx + 1, bot | (i != mn), top | (i != mx), 1, 1-par, (rem*10%m+i)%m))%mod;
		}
	}
	return dp[idx][bot][top][put][par][rem] = ans;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> m >> d;
	cin >> lo >> hi;
	timer++;
	cout << solve() << "\n";
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;

int m, d, n;
string lo, hi;
int dp[2000][2][2][2][2][2000];

int solve(int idx = 0, int put = 0, int par = 0, int bot = 0, int top = 0, int rem = 0) {
	if (idx == n)
		return (put && rem==0);

	if (dp[idx][put][par][bot][top][rem] != -1) return dp[idx][put][par][bot][top][rem];

	int ans = 0;
	int mn = bot ? 0 : lo[idx]-'0';
	int mx = top ? 9 : hi[idx]-'0';
	if (!idx || !put) {
		for (int i = mn; i <= mx; ++i) {
			if (i==d) continue;
			ans = (ans + solve(idx + 1, (i!=0), 0, bot | (i!=mn), top | (i!=mx), ((rem*10) % m + i) % m)) % MOD;
		}
	} else {
		for (int i = mn; i <= mx; ++i) {
			if (par == (i!=d))
				ans = (ans + solve(idx + 1, put, !par, bot | (i!=mn), top | (i!=mx), ((rem*10) % m + i) % m)) % MOD;
		}
	}

	return dp[idx][put][par][bot][top][rem] = ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	cin >> m >> d;
	cin >> lo >> hi;
	n = lo.size();
	memset(dp, -1, sizeof(dp));
	cout << solve() << "\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[2005][2][2005][2][2];
vector<ll> v;
ll m,d,a,b;
ll hf(ll pos , ll f , ll mo , ll even , ll st)
{
    if(pos == v.size())
        return (mo == 0);
    if(dp[pos][f][mo][even][st]!=-1)
        return dp[pos][f][mo][even][st];
    ll ans = 0;
    ll lmt;
    if(f)
        lmt = 9;
    else
        lmt = v[pos];
    if(st == 0)
    {
        ans = (ans + hf(pos+1 , f & (v[pos]>0) , mo , even , st))%1000000007;
        for(ll i=1 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(i!=d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,1,1))%1000000007;
        }
    }
    else
    {
        for(ll i=0 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(even && i==d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
            else if(!even && i != d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
        }

    }
    return dp[pos][f][mo][even][st] = ans;
}
ll solve(ll num)
{
    v.clear();
    while(num)
    {
        v.push_back(num%10);
        num /= 10;
    }
    reverse(v.begin(),v.end());
    memset(dp,-1,sizeof(dp));
    ll ans = hf(0,0,0,0,0);
    return ans;
}
int main()
{
    cin>>m>>d;
    cin>>a>>b;
    ll ans = solve(b) - solve(a-1);
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[2005][2][2005][2][2];
vector<ll> v;
ll m,d,a,b;
ll hf(ll pos , ll f , ll mo , ll even , ll st)
{
    if(pos == v.size())
        return (mo == 0);
    if(dp[pos][f][mo][even][st]!=-1)
        return dp[pos][f][mo][even][st];
    ll ans = 0;
    ll lmt;
    if(f)
        lmt = 9;
    else
        lmt = v[pos];
    if(st == 0)
    {
        ans = (ans + hf(pos+1 , f || (v[pos]>0) , mo , even , st))%1000000007;
        for(ll i=1 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(i!=d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,1,1))%1000000007;
        }
    }
    else
    {
        for(ll i=0 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(even && i==d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
            else if(!even && i != d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
        }

    }
    return dp[pos][f][mo][even][st] = ans;
}
ll solve(ll num)
{
    v.clear();
    while(num)
    {
        v.push_back(num%10);
        num /= 10;
    }
    reverse(v.begin(),v.end());
    memset(dp,-1,sizeof(dp));
    ll ans = hf(0,0,0,0,0);
    return ans;
}
int main()
{
    cin>>m>>d;
    cin>>a>>b;
    ll ans = solve(b) - solve(a-1);
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[2005][2][2005][2][2];
string v;
ll m,d;
string a,b;
ll hf(ll pos , ll f , ll mo , ll even , ll st)
{
    if(pos == v.size())
        return (mo == 0);
    if(dp[pos][f][mo][even][st]!=-1)
        return dp[pos][f][mo][even][st];
    ll ans = 0;
    ll lmt;
    if(f)
        lmt = 9;
    else
        lmt = v[pos] - '0';
    if(st == 0)
    {
        ans = (ans + hf(pos+1 , f || ((v[pos] - '0')>0) , mo , even , st))%1000000007;
        for(ll i=1 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(i!=d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,1,1))%1000000007;
        }
    }
    else
    {
        for(ll i=0 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(even && i==d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
            else if(!even && i != d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
        }

    }
    return dp[pos][f][mo][even][st] = ans;
}
ll solve(string num)
{
    v = num;
    //reverse(v.begin(),v.end());
    memset(dp,-1,sizeof(dp));
    ll ans = hf(0,0,0,0,0);
    return ans;
}
int main()
{
    cin>>m>>d;
    cin>>a>>b;
    ll ans = (solve(b) - solve(a) + 1000000007)%1000000007;
    ll mo = 0;
    bool flg = 1;
    for ( ll i = 0; i < a.size(); i ++){
        if ( i%2 and ((a[i]-'0')!=d))
            flg = 0;
        if ( i%2==0 and ((a[i]-'0')==d))
            flg = 0;
        mo = (mo*10 + (a[i]-'0'))%m;
    }
    if ( mo == 0 and flg ){
        ans = ( ans + 1 )%1000000007;
    }
    //cout << ans;
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[2005][2][2005][2][2];
vector<ll> v;
ll m,d,a,b;
ll hf(ll pos , ll f , ll mo , ll even , ll st)
{
    if(pos == v.size())
        return (mo == 0);
    if(dp[pos][f][mo][even][st]!=-1)
        return dp[pos][f][mo][even][st];
    ll ans = 0;
    ll lmt;
    if(f)
        lmt = 9;
    else
        lmt = v[pos];
    if(st == 0)
    {
        ans = ans + hf(pos+1 , f , mo , even , st);
        for(ll i=1 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(i!=d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,1,1))%1000000007;
        }
    }
    else
    {
        for(ll i=0 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(even && i==d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
            else if(!even && i != d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
        }

    }
    return dp[pos][f][mo][even][st] = ans;
}
ll solve(ll num)
{
    v.clear();
    while(num)
    {
        v.push_back(num%10);
        num /= 10;
    }
    reverse(v.begin(),v.end());
    memset(dp,-1,sizeof(dp));
    ll ans = hf(0,0,0,0,0);
    return ans;
}
int main()
{
    cin>>m>>d;
    cin>>a>>b;
    ll ans = solve(b) - solve(a-1);
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[2005][2][2005][2][2];
vector<ll> v;
ll m,d,a,b;
ll hf(ll pos , ll f , ll mo , ll even , ll st)
{
    if(pos == v.size())
        return (mo == 0);
    if(dp[pos][f][mo][even][st]!=-1)
        return dp[pos][f][mo][even][st];
    ll ans = 0;
    ll lmt;
    if(f)
        lmt = 9;
    else
        lmt = v[pos];
    if(st == 0)
    {
        ans = (ans + hf(pos+1 , f , mo , even , st))%1000000007;
        for(ll i=1 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(i!=d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,1,1))%1000000007;
        }
    }
    else
    {
        for(ll i=0 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(even && i==d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
            else if(!even && i != d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
        }

    }
    return dp[pos][f][mo][even][st] = ans;
}
ll solve(ll num)
{
    v.clear();
    while(num)
    {
        v.push_back(num%10);
        num /= 10;
    }
    reverse(v.begin(),v.end());
    memset(dp,-1,sizeof(dp));
    ll ans = hf(0,0,0,0,0);
    return ans;
}
int main()
{
    cin>>m>>d;
    cin>>a>>b;
    ll ans = solve(b) - solve(a-1);
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef int ll;
ll dp[2005][2][2005][2][2];
string v;
ll m,d;
string a,b;
ll hf(ll pos , ll f , ll mo , ll even , ll st)
{
    if(pos == v.size())
        return (mo == 0);
    if(dp[pos][f][mo][even][st]!=-1)
        return dp[pos][f][mo][even][st];
    ll ans = 0;
    ll lmt;
    if(f)
        lmt = 9;
    else
        lmt = v[pos] - '0';
    if(st == 0)
    {
        ans = (ans + hf(pos+1 , f || ((v[pos] - '0')>0) , mo , even , st))%1000000007;
        for(ll i=1 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(i!=d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,1,1))%1000000007;
        }
    }
    else
    {
        for(ll i=0 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(even && i==d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
            else if(!even && i != d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
        }

    }
    return dp[pos][f][mo][even][st] = ans;
}
ll solve(string num)
{
    v = num;
    //reverse(v.begin(),v.end());
    memset(dp,-1,sizeof(dp));
    ll ans = hf(0,0,0,0,0);
    return ans;
}
int main()
{
    cin>>m>>d;
    cin>>a>>b;
    ll ans = (solve(b) - solve(a) + 1000000007)%1000000007;
    ll mo = 0;
    bool flg = 1;
    for ( ll i = 0; i < a.size(); i ++){
        if ( i%2 and ((a[i]-'0')!=d))
            flg = 0;
        if ( i%2==0 and ((a[i]-'0')==d))
            flg = 0;
        mo = (mo*10 + (a[i]-'0'))%m;
    }
    if ( mo == 0 and flg ){
        ans = ( ans + 1 )%1000000007;
    }
    //cout << ans;
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[2005][2][2005][2][2];
string v;
ll m,d;
string a,b;
ll hf(ll pos , ll f , ll mo , ll even , ll st)
{
    if(pos == v.size())
        return (mo == 0);
    if(dp[pos][f][mo][even][st]!=-1)
        return dp[pos][f][mo][even][st];
    ll ans = 0;
    ll lmt;
    if(f)
        lmt = 9;
    else
        lmt = v[pos] - '0';
    if(st == 0)
    {
        ans = (ans + hf(pos+1 , f || ((v[pos] - '0')>0) , mo , even , st))%1000000007;
        for(ll i=1 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(i!=d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,1,1))%1000000007;
        }
    }
    else
    {
        for(ll i=0 ; i<=lmt ; i++)
        {
            ll nf = f;
            if(i<lmt)
                nf = 1;
            if(even && i==d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
            else if(!even && i != d)
                ans = (ans + hf(pos+1,nf,(mo*10+i)%m,!even,1))%1000000007;
        }

    }
    return dp[pos][f][mo][even][st] = ans;
}
ll solve(string num)
{
    v = num;
    //reverse(v.begin(),v.end());
    memset(dp,-1,sizeof(dp));
    ll ans = hf(0,0,0,0,0);
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>m>>d;
    cin>>a>>b;
    ll ans = (solve(b) - solve(a) + 1000000007)%1000000007;
    ll mo = 0;
    bool flg = 1;
    for ( ll i = 0; i < a.size(); i ++){
        if ( i%2 and ((a[i]-'0')!=d))
            flg = 0;
        if ( i%2==0 and ((a[i]-'0')==d))
            flg = 0;
        mo = (mo*10 + (a[i]-'0'))%m;
    }
    if ( mo == 0 and flg ){
        ans = ( ans + 1 )%1000000007;
    }
    //cout << ans;
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;
ll mod = 1000000007;
ll dp[ 2005 ][ 2005 ][ 2 ][ 2 ][ 2 ];
string s;
string a,b;
ll d,m;
ll solve ( ll pos, ll mo, bool tight, bool st, bool even){
    if ( pos == s.size() )
        return (mo==0);
    if ( dp[pos][mo][tight][st][even] != -1 )
        return dp[pos][mo][tight][st][even];
    ll ret = 0;
    ll en = (tight?(s[pos]-'0'):9);
    if ( st == 0 ){
        ret = ( ret + solve(pos+1,mo,tight&(s[pos]=='0'),st,0))%mod;
        for ( ll i = 1; i <= en; i ++)
            if ( i != d )
                ret = ( ret + solve(pos+1,(mo*10 + i)%m,tight&(i==en),1,1))%mod;
    }
    else{
        for ( ll i = 0; i <= en; i ++)
        {
            if ( even and (i==d) )
                ret = ( ret + solve(pos+1,(mo*10 + i)%m,tight&(i==en),1,!even))%mod;
            else if ( (!even) and (i!=d) )
                ret = ( ret + solve(pos+1,(mo*10 + i)%m,tight&(i==en),1,!even))%mod;
        }
    }
    return dp[pos][mo][tight][st][even] = ret;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> m >> d;
    cin >> a >> b;
    s = b;
    memset(dp,-1,sizeof dp);
    ll ans = solve(0,0,1,0,0);
    s = a;
    memset(dp,-1,sizeof dp);
    ans = (ans - solve(0,0,1,0,0) + mod)%mod;
    ll mo = 0;
    bool flg = 1;
    for ( ll i = 0; i < a.size(); i ++){
        if ( i%2 and ((a[i]-'0')!=d))
            flg = 0;
        if ( i%2==0 and ((a[i]-'0')==d))
            flg = 0;
        mo = (mo*10 + (a[i]-'0'))%m;
    }
    if ( mo == 0 and flg ){
        ans = ( ans + 1 )%mod;
    }
    cout << ans;

}


#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;
ll mod = 1000000007;
ll dp[ 2005 ][ 2005 ][ 2 ][ 2 ][ 2 ];
string s;
string a,b;
ll d,m;
ll solve ( ll pos, ll mo, bool tight, bool st, bool even){
    if ( pos == s.size() )
        return (mo==0);
    if ( dp[pos][mo][tight][st][even] != -1 )
        return dp[pos][mo][tight][st][even];
    ll ret = 0;
    ll en = (tight?(s[pos]-'0'):9);
    if ( st == 0 ){
        ret = ( ret + solve(pos+1,mo,tight&(s[pos]=='0'),st,0))%mod;
        for ( ll i = 1; i <= en; i ++)
            if ( i != d )
                ret = ( ret + solve(pos+1,(mo*10 + i)%m,tight&(i==en),1,1))%mod;
    }
    else{
        for ( ll i = 0; i <= en; i ++)
        {
            if ( even and (i==d) )
                ret = ( ret + solve(pos+1,(mo*10 + i)%m,tight&(i==en),1,!even))%mod;
            else if ( (!even) and (i!=d) )
                ret = ( ret + solve(pos+1,(mo*10 + i)%m,tight&(i==en),1,!even))%mod;
        }
    }
    return dp[pos][mo][tight][st][even] = ret;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    cin >> m >> d;
    cin >> a >> b;
    s = b;
    memset(dp,-1,sizeof dp);
    ll ans = solve(0,0,1,0,0);
    s = a;
    memset(dp,-1,sizeof dp);
    ans = (ans - solve(0,0,1,0,0) + mod)%mod;
    ll mo = 0;
    bool flg = 1;
    for ( ll i = 0; i < a.size(); i ++){
        if ( i%2 and ((a[i]-'0')!=d))
            flg = 0;
        if ( i%2==0 and ((a[i]-'0')==d))
            flg = 0;
        mo = (mo*10 + (a[i]-'0'))%m;
    }
    if ( mo == 0 and flg ){
        ans = ( ans + 1 )%mod;
    }
    cout << ans;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define f(i, a, n) for (ll i = a; i < n; i++)
#define fb(i, a, n) for (ll i = n - 1; i >= a; i--)

#define pr pair<ll, ll>
#define vr vector<ll>
#define vp vector<pair<ll, ll>>

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mem(x, y) memset(x, y, sizeof(x))
ll dp[2000][2000][2];

void append_zero(string&a, string& b){
    int m = a.size();
    int n = b.size();
    string temp = "";
    for(int i=0;i<n-m;i++){
        temp+='0';
    }
    temp+=a;
    a = temp;
    return ;
}

void reset(int n=2000,int m=2000){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<2;k++){
                dp[i][j][k] = -1;
            }
        }
    }
}

ll solve(int pos,int mod,int tight,string& a,int m,int d){
    if(pos==a.size()){
        return mod%m==0;
    }

    if(dp[pos][mod][tight]!=-1){
        return dp[pos][mod][tight];
    }

    ll ans = 0;
    if(pos&1){
        int temp = mod*10;
        temp+=d;
        temp%=m;
        if(tight){
            if(d > (a[pos]-'0')){
                ans = 0;
            }
            else{
                ans = solve(pos+1,temp,tight&&((a[pos]-'0')==d),a,m,d);
            }
        }
        else{
            ans = solve(pos+1,temp,tight,a,m,d);
        }
    }
    else{
        int upper = tight?a[pos]-'0':9;
        for(int i=0;i<=upper;i++){
            if(i==d){
                continue;
            }
            int temp = mod*10;
            temp+=i;
            temp%=m;
            ans+=solve(pos+1,temp,tight&&(a[pos]-'0'==i),a,m,d);
            ans%=MOD;
        }
    }
    return dp[pos][mod][tight]=ans;

}

bool check(string& a,int m,int d){    int mod = 0;
    for(int i=0;i<a.size();i++){
        if(i&1){
            if(a[i]-'0'!=d){
                return false;
            }
            else{
                mod*=10;
                mod+=d;
                mod%=m;
            }
        }
        else{
            mod*=10;
            mod+=(a[i]-'0');
            mod%=m;
        }
    }
    return mod==0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--)
    {
       int m,d;
       cin >> m >> d;
       string a,b;
       cin >> a >> b;
       append_zero(a,b);
       reset();
       ll ans = solve(0,0,1,b,m,d);
       reset();
       ans -= solve(0,0,1,a,m,d);
       ans+=MOD;
       ans%=MOD;
       ans+=check(a,m,d);
       ans%=MOD;
       cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define f(i, a, n) for (ll i = a; i < n; i++)
#define fb(i, a, n) for (ll i = n - 1; i >= a; i--)

#define pr pair<ll, ll>
#define vr vector<ll>
#define vp vector<pair<ll, ll>>

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mem(x, y) memset(x, y, sizeof(x))
ll dp[2000][2000][2];

void append_zero(string&a, string& b){
    int m = a.size();
    int n = b.size();
    string temp = "";
    for(int i=0;i<n-m;i++){
        temp+='0';
    }
    temp+=a;
    a = temp;
    return ;
}

void reset(int n=2000,int m=2000){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<2;k++){
                dp[i][j][k] = -1;
            }
        }
    }
}

ll solve(int pos,int mod,int tight,string& a,int m,int d){
    if(pos==a.size()){
        return mod%m==0;
    }

    if(dp[pos][mod][tight]!=-1){
        return dp[pos][mod][tight];
    }

    ll ans = 0;
    if(pos&1){
        int temp = mod*10;
        temp+=d;
        temp%=m;
        if(tight){
            if(d > (a[pos]-'0')){
                ans = 0;
            }
            else{
                ans = solve(pos+1,temp,tight&&((a[pos]-'0')==d),a,m,d);
            }
        }
        else{
            ans = solve(pos+1,temp,tight,a,m,d);
        }
    }
    else{
        int upper = tight?a[pos]-'0':9;
        for(int i=0;i<=upper;i++){
            if(i==d){
                continue;
            }
            int temp = mod*10;
            temp+=i;
            temp%=m;
            ans+=solve(pos+1,temp,tight&&(a[pos]-'0'==i),a,m,d);
            ans%=MOD;
        }
    }
    return dp[pos][mod][tight]=ans;

}

bool check(string& a,int m,int d){
    int mod = 0;
    for(int i=0;i<a.size();i++){
        if(i&1){
            if(a[i]-'0'!=d){
                return false;
            }
            else{
                mod*=10;
                mod+=d;
                mod%=m;
            }
        }
        else if(a[i]-'0'==d){
            return false;
        }
        else{
            mod*=10;
            mod+=(a[i]-'0');
            mod%=m;
        }
    }
    return mod==0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--)
    {
       int m,d;
       cin >> m >> d;
       string a,b;
       cin >> a >> b;
       append_zero(a,b);
       reset();
       ll ans = solve(0,0,1,b,m,d);
       reset();
       ans -= solve(0,0,1,a,m,d);
       ans+=MOD;
       ans%=MOD;
       ans+=check(a,m,d);
       ans%=MOD;
       cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define f(i, a, n) for (ll i = a; i < n; i++)
#define fb(i, a, n) for (ll i = n - 1; i >= a; i--)

#define pr pair<ll, ll>
#define vr vector<ll>
#define vp vector<pair<ll, ll>>

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mem(x, y) memset(x, y, sizeof(x))
ll dp[2000][2000][2];

void append_zero(string&a, string& b){
    int m = a.size();
    int n = b.size();
    string temp = "";
    for(int i=0;i<n-m;i++){
        temp+='0';
    }
    temp+=a;
    a = temp;
    return ;
}

void reset(int n=2000,int m=2000){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<2;k++){
                dp[i][j][k] = -1;
            }
        }
    }
}

ll solve(int pos,int mod,int tight,string& a,int m,int d){
    if(pos==a.size()){
        return mod%m==0;
    }

    if(dp[pos][mod][tight]!=-1){
        return dp[pos][mod][tight];
    }

    ll ans = 0;
    if(pos&1){
        int temp = mod*10;
        temp+=d;
        temp%=m;
        if(tight){
            if(d > (a[pos]-'0')){
                ans = 0;
            }
            else{
                ans = solve(pos+1,temp,tight&&((a[pos]-'0')==d),a,m,d);
            }
        }
        else{
            ans = solve(pos+1,temp,tight,a,m,d);
        }
    }
    else{
        int upper = tight?a[pos]-'0':9;
        for(int i=0;i<=upper;i++){
            if(i==d){
                continue;
            }
            int temp = mod*10;
            temp+=i;
            temp%=m;
            ans+=solve(pos+1,temp,tight&&(a[pos]-'0'==i),a,m,d);
            ans%=MOD;
        }
    }
    return dp[pos][mod][tight]=ans;

}

bool check(string& a,int m,int d){
    int mod = 0;
    for(int i=0;i<a.size();i++){
        if(i&1){
            if(a[i]-'0'!=d){
                return false;
            }
            else{
                mod*=10;
                mod+=d;
                mod%=m;
            }
        }
        else{
            mod*=10;
            mod+=(a[i]-'0');
            mod%=m;
        }
    }
    return mod==0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--)
    {
       int m,d;
       cin >> m >> d;
       string a,b;
       cin >> a >> b;
       append_zero(a,b);
       if(a.size()==1 and b.size()==1){
           cout << ceil((b[0]-a[0]+0.0)/m) << endl;
           return 0;
       }
       reset();
       ll ans = solve(0,0,1,b,m,d);
       reset();
       ans -= solve(0,0,1,a,m,d);
       ans+=MOD;
       ans%=MOD;
       ans+=check(a,m,d);
       ans%=MOD;
       cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define f(i, a, n) for (ll i = a; i < n; i++)
#define fb(i, a, n) for (ll i = n - 1; i >= a; i--)

#define pr pair<ll, ll>
#define vr vector<ll>
#define vp vector<pair<ll, ll>>

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mem(x, y) memset(x, y, sizeof(x))
ll dp[2000][2000][2];

void append_zero(string&a, string& b){
    int m = a.size();
    int n = b.size();
    string temp = "";
    for(int i=0;i<n-m;i++){
        temp+='0';
    }
    temp+=a;
    a = temp;
    return ;
}

void reset(int n=2000,int m=2000){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<2;k++){
                dp[i][j][k] = -1;
            }
        }
    }
}

ll solve(int pos,int mod,int tight,string& a,int m,int d){
    if(pos==a.size()){
        return mod%m==0;
    }

    if(dp[pos][mod][tight]!=-1){
        return dp[pos][mod][tight];
    }

    ll ans = 0;
    if(pos&1){
        int temp = mod*10;
        temp+=d;
        temp%=m;
        if(tight){
            if(d > (a[pos]-'0')){
                ans = 0;
            }
            else{
                ans = solve(pos+1,temp,tight&&((a[pos]-'0')==d),a,m,d);
            }
        }
        else{
            ans = solve(pos+1,temp,tight,a,m,d);
        }
    }
    else{
        int upper = tight?a[pos]-'0':9;
        for(int i=0;i<=upper;i++){
            if(i==d){
                continue;
            }
            int temp = mod*10;
            temp+=i;
            temp%=m;
            ans+=solve(pos+1,temp,tight&&(a[pos]-'0'==i),a,m,d);
            ans%=MOD;
        }
    }
    return dp[pos][mod][tight]=ans;

}

bool check(string& a,int m,int d){
    int mod = 0;
    for(int i=0;i<a.size();i++){
        if(i&1){
            if(a[i]-'0'!=d){
                return false;
            }
            else{
                mod*=10;
                mod+=d;
                mod%=m;
            }
        }
        else{
            mod*=10;
            mod+=(a[i]-'0');
            mod%=m;
        }
    }
    return mod==0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--)
    {
       int m,d;
       cin >> m >> d;
       string a,b;
       cin >> a >> b;
       append_zero(a,b);
       if(a.size()==1 and b.size()==1){
           cout << (b[0]-a[0])/m << endl;
           return 0;
       }
       reset();
       ll ans = solve(0,0,1,b,m,d);
       reset();
       ans -= solve(0,0,1,a,m,d);
       ans+=MOD;
       ans%=MOD;
       ans+=check(a,m,d);
       ans%=MOD;
       cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define f(i, a, n) for (ll i = a; i < n; i++)
#define fb(i, a, n) for (ll i = n - 1; i >= a; i--)

#define pr pair<ll, ll>
#define vr vector<ll>
#define vp vector<pair<ll, ll>>

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mem(x, y) memset(x, y, sizeof(x))
ll dp[2000][2000][2];

void append_zero(string&a, string& b){
    int m = a.size();
    int n = b.size();
    string temp = "";
    for(int i=0;i<n-m;i++){
        temp+='0';
    }
    temp+=a;
    a = temp;
    return ;
}

void reset(int n=2000,int m=2000){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<2;k++){
                dp[i][j][k] = -1;
            }
        }
    }
}

ll solve(int pos,int mod,int tight,string& a,int m,int d){
    if(pos==a.size()){
        return mod%m==0;
    }

    if(dp[pos][mod][tight]!=-1){
        return dp[pos][mod][tight];
    }

    ll ans = 0;
    if(pos&1){
        int temp = mod*10;
        temp+=d;
        temp%=m;
        if(tight){
            if(d > (a[pos]-'0')){
                ans = 0;
            }
            else{
                ans = solve(pos+1,temp,tight&&((a[pos]-'0')==d),a,m,d);
            }
        }
        else{
            ans = solve(pos+1,temp,tight,a,m,d);
        }
    }
    else{
        int upper = tight?a[pos]-'0':9;
        for(int i=0;i<=upper;i++){
            if(i==d){
                continue;
            }
            int temp = mod*10;
            temp+=i;
            temp%=m;
            ans+=solve(pos+1,temp,tight&&(a[pos]-'0'==i),a,m,d);
            ans%=MOD;
        }
    }
    return dp[pos][mod][tight]=ans;

}

bool check(string& a,int m,int d){
    int mod = 0;
    for(int i=0;i<a.size();i++){
        if(i&1){
            if(a[i]-'0'!=d){
                return false;
            }
            else{
                mod*=10;
                mod+=d;
                mod%=m;
            }
        }
        else{
            mod*=10;
            mod+=(a[i]-'0');
            mod%=m;
        }
    }
    return mod==0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--)
    {
       int m,d;
       cin >> m >> d;
       string a,b;
       cin >> a >> b;
       append_zero(a,b);
       if(a.size()==1 and b.size()==1){
           cout << (b[0]-a[0]) << endl;
           return 0;
       }
       reset();
       ll ans = solve(0,0,1,b,m,d);
       reset();
       ans -= solve(0,0,1,a,m,d);
       ans+=MOD;
       ans%=MOD;
       ans+=check(a,m,d);
       ans%=MOD;
       cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define f(i, a, n) for (ll i = a; i < n; i++)
#define fb(i, a, n) for (ll i = n - 1; i >= a; i--)

#define pr pair<ll, ll>
#define vr vector<ll>
#define vp vector<pair<ll, ll>>

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mem(x, y) memset(x, y, sizeof(x))
ll dp[2000][2000][2];

void append_zero(string&a, string& b){
    int m = a.size();
    int n = b.size();
    string temp = "";
    for(int i=0;i<n-m;i++){
        temp+='0';
    }
    temp+=a;
    a = temp;
    return ;
}

void reset(int n=2000,int m=2000){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<2;k++){
                dp[i][j][k] = -1;
            }
        }
    }
}

ll solve(int pos,int mod,int tight,string& a,int m,int d){
    if(pos==a.size()){
        return mod%m==0;
    }

    if(dp[pos][mod][tight]!=-1){
        return dp[pos][mod][tight];
    }

    ll ans = 0;
    if(pos&1){
        int temp = mod*10;
        temp+=d;
        temp%=m;
        if(tight){
            if(d > (a[pos]-'0')){
                ans = 0;
            }
            else{
                ans = solve(pos+1,temp,tight&&((a[pos]-'0')==d),a,m,d);
            }
        }
        else{
            ans = solve(pos+1,temp,tight,a,m,d);
        }
    }
    else{
        int upper = tight?a[pos]-'0':9;
        for(int i=0;i<=upper;i++){
            if(i==d){
                continue;
            }
            int temp = mod*10;
            temp+=i;
            temp%=m;
            ans+=solve(pos+1,temp,tight&&(a[pos]-'0'==i),a,m,d);
            ans%=MOD;
        }
    }
    return dp[pos][mod][tight]=ans;

}

bool check(string& a,int m,int d){
    int mod = 0;
    for(int i=0;i<a.size();i++){
        if(i&1){
            if(a[i]-'0'!=d){
                return false;
            }
            else{
                mod*=10;
                mod+=d;
                mod%=m;
            }
        }
        else{
            mod*=10;
            mod+=(a[i]-'0');
            mod%=m;
        }
    }
    return mod==0 && a.size()!=1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--)
    {
       int m,d;
       cin >> m >> d;
       string a,b;
       cin >> a >> b;
       append_zero(a,b);
       reset();
       ll ans = solve(0,0,1,b,m,d);
       reset();
       ans -= solve(0,0,1,a,m,d);
       ans+=MOD;
       ans%=MOD;
       ans+=check(a,m,d);
       ans%=MOD;
       cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define f(i, a, n) for (ll i = a; i < n; i++)
#define fb(i, a, n) for (ll i = n - 1; i >= a; i--)

#define pr pair<ll, ll>
#define vr vector<ll>
#define vp vector<pair<ll, ll>>

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mem(x, y) memset(x, y, sizeof(x))
ll dp[2000][2000][2];

void append_zero(string&a, string& b){
    int m = a.size();
    int n = b.size();
    string temp = "";
    for(int i=0;i<n-m;i++){
        temp+='0';
    }
    temp+=a;
    a = temp;
    return ;
}

void reset(int n=2000,int m=2000){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<2;k++){
                dp[i][j][k] = -1;
            }
        }
    }
}

ll solve(int pos,int mod,int tight,string& a,int m,int d){
    if(pos==a.size()){
        return mod%m==0;
    }

    if(dp[pos][mod][tight]!=-1){
        return dp[pos][mod][tight];
    }

    ll ans = 0;
    if(pos&1){
        int temp = mod*10;
        temp+=d;
        temp%=m;
        if(tight){
            if(d > (a[pos]-'0')){
                ans = 0;
            }
            else{
                ans = solve(pos+1,temp,tight&&((a[pos]-'0')==d),a,m,d);
            }
        }
        else{
            ans = solve(pos+1,temp,tight,a,m,d);
        }
    }
    else{
        int upper = tight?a[pos]-'0':9;
        for(int i=0;i<=upper;i++){
            if(i==d){
                continue;
            }
            int temp = mod*10;
            temp+=i;
            temp%=m;
            ans+=solve(pos+1,temp,tight&&(a[pos]-'0'==i),a,m,d);
            ans%=MOD;
        }
    }
    return dp[pos][mod][tight]=ans;

}

bool check(string& a,int m,int d){
    int mod = 0;
    for(int i=0;i<a.size();i++){
        if(i&1){
            if(a[i]-'0'!=d){
                return false;
            }
            else{
                mod*=10;
                mod+=d;
                mod%=m;
            }
        }
        else{
            mod*=10;
            mod+=(a[i]-'0');
            mod%=m;
        }
    }
    return mod==0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--)
    {
       int m,d;
       cin >> m >> d;
       string a,b;
       cin >> a >> b;
       append_zero(a,b);
       reset();
       ll ans = solve(0,0,1,b,m,d);
       reset();
       ans -= solve(0,0,1,a,m,d);
       ans+=MOD;
       ans%=MOD;
    //    ans+=check(a,m,d);
       ans%=MOD;
       cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define f(i, a, n) for (ll i = a; i < n; i++)
#define fb(i, a, n) for (ll i = n - 1; i >= a; i--)

#define pr pair<ll, ll>
#define vr vector<ll>
#define vp vector<pair<ll, ll>>

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mem(x, y) memset(x, y, sizeof(x))
ll dp[2000][2000][2];

void append_zero(string&a, string& b){
    int m = a.size();
    int n = b.size();
    string temp = "";
    for(int i=0;i<n-m;i++){
        temp+='0';
    }
    temp+=a;
    a = temp;
    return ;
}

void reset(int n=2000,int m=2000){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<2;k++){
                dp[i][j][k] = -1;
            }
        }
    }
}

ll solve(int pos,int mod,int tight,string& a,int m,int d){
    if(pos==a.size()){
        return mod%m==0;
    }

    if(dp[pos][mod][tight]!=-1){
        return dp[pos][mod][tight];
    }

    ll ans = 0;
    if(pos&1){
        int temp = mod*10;
        temp+=d;
        temp%=m;
        if(tight){
            if(d > (a[pos]-'0')){
                ans = 0;
            }
            else{
                ans = solve(pos+1,temp,tight&&((a[pos]-'0')==d),a,m,d);
            }
        }
        else{
            ans = solve(pos+1,temp,tight,a,m,d);
        }
    }
    else{
        int upper = tight?a[pos]-'0':9;
        for(int i=0;i<=upper;i++){
            if(i==d){
                continue;
            }
            int temp = mod*10;
            temp+=i;
            temp%=m;
            ans+=solve(pos+1,temp,tight&&(a[pos]-'0'==i),a,m,d);
        }
    }
    return dp[pos][mod][tight]=ans;

}

bool check(string& a,int m,int d){    int mod = 0;
    for(int i=0;i<a.size();i++){
        if(i&1){
            if(a[i]-'0'!=d){
                return false;
            }
            else{
                mod*=10;
                mod+=d;
                mod%=m;
            }
        }
        else{
            mod*=10;
            mod+=(a[i]-'0');
            mod%=m;
        }
    }
    return mod==0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--)
    {
       int m,d;
       cin >> m >> d;
       string a,b;
       cin >> a >> b;
       append_zero(a,b);
       reset();
       ll ans = solve(0,0,1,b,m,d);
       reset();
       ans -= solve(0,0,1,a,m,d);
       ans+=MOD;
       ans%=MOD;
       ans+=check(a,m,d);
       ans%=MOD;
       cout << ans << endl;
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#define ft(i,a,b) for(int i=a; i<=b; ++i)

using namespace std;

long f[2000][2000][4],m,d;
const int mod = 100;
string a,b;

int calc(const string &a)
{
    int len=a.size();
    memset(f,0,sizeof(f));
    ft(x,1,9) {
        if (x==d) continue;
        int st=1;
        int de=a[1]-'0';
        if (x>a[0]-'0') st=2;
        if (x<a[0]-'0') st=0;
        f[1][x%m][st]++;
    }
    ft(i,1,len)
    {
        ft(r,0,m-1)
        {
            ft(st,0,2)
            {
                if (f[i][r][st]==0) continue;
                ft(x,0,9)
                {
                    if (i % 2 == 0 && x == d) {
                        continue;
                    }
                    if (i % 2 == 1 && x != d) {
                        continue;
                    }
                    int newst=st;
                    int newr=(r*10+x)%m;
                    if (newst==1)
                    {
                        if (x>a[i]-'0') newst=2;
                        if (x<a[i]-'0') newst=0;
                        if (x==a[i]-'0') newst=1;
                    }
                    f[i+1][newr][newst]+=f[i][r][st];
                }
            }
        }
    }
    int ans=0;
    ans=f[len][0][1]+f[len][0][0];
    return ans;
}

int check(const string& a)
{
    for(int i=0; i<a.size(); ++i)
    {
        if (i%2==1&&a[i]!=d) return 0;
    }
}

int main()
{
//    freopen("INPUT.TXT","r",stdin);
//    freopen("OUTPUT.TXT","w",stdout);
    cin>>m>>d>>a>>b;
    cout<<calc(b)-calc(a)+check(a);
    return 0;
}


#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#define ft(i,a,b) for(int i=a; i<=b; ++i)

using namespace std;

long long f[2010][2010][4],m,d;
const long MOD = 1000000007;
string a,b;

long long calc(const string &a)
{
    int len=a.size();
    memset(f,0,sizeof(f));
    ft(x,1,9) {
        if (x==d) continue;
        int st=1;
        if (x>a[0]-'0') st=2;
        if (x<a[0]-'0') st=0;
        f[1][x%m][st]++;
    }
    ft(i,1,len)
    {
        ft(r,0,m-1)
        {
            ft(st,0,2)
            {
                if (f[i][r][st]==0) continue;
                ft(x,0,9)
                {
                    if (i % 2 == 0 && x == d) {
                        continue;
                    }
                    if (i % 2 == 1 && x != d) {
                        continue;
                    }
                    int newst=st;
                    int newr=(r*10+x)%m;
                    if (newst==1)
                    {
                        if (x>a[i]-'0') newst=2;
                        if (x<a[i]-'0') newst=0;
                        if (x==a[i]-'0') newst=1;
                    }
                    (f[i+1][newr][newst]+=f[i][r][st])%=MOD;
                }
            }
        }
    }
    long long ans=f[len][0][0];
    (ans+=f[len][0][1])%=MOD;
    return ans;
}

int check(const string& a)
{
    for(int i=0; i<a.size(); ++i)
    {
        if (i%2==1&&a[i]-'0'!=d) return 0;
        if (i%2==0&&a[i]-'0'==d) return 0;
    }
    int f=a[0]-'0';
    for(int i=1; i<a.size(); ++i)
    {
        f=(f*10+a[i]-'0')%m;
    }
    return f%m==0;
}

int main()
{
    //freopen("INPUT.TXT","r",stdin);
//    freopen("OUTPUT.TXT","w",stdout);
    cin>>m>>d>>a>>b;
    long ans=(calc(b)-calc(a)+MOD)%MOD;
    ans+=check(a);
    ans%=MOD;
    cout<<ans;
    return 0;
}


#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#define ft(i,a,b) for(int i=a; i<=b; ++i)

using namespace std;

long long f[2000][2000][4],m,d;
const long MOD = 1000000007;
string a,b;

long long calc(const string &a)
{
    int len=a.size();
    memset(f,0,sizeof(f));
    ft(x,1,9) {
        if (x==d) continue;
        int st=1;
        if (x>a[0]-'0') st=2;
        if (x<a[0]-'0') st=0;
        f[1][x%m][st]++;
    }
    ft(i,1,len)
    {
        ft(r,0,m-1)
        {
            ft(st,0,2)
            {
                if (f[i][r][st]==0) continue;
                ft(x,0,9)
                {
                    if (i % 2 == 0 && x == d) {
                        continue;
                    }
                    if (i % 2 == 1 && x != d) {
                        continue;
                    }
                    int newst=st;
                    int newr=(r*10+x)%m;
                    if (newst==1)
                    {
                        if (x>a[i]-'0') newst=2;
                        if (x<a[i]-'0') newst=0;
                        if (x==a[i]-'0') newst=1;
                    }
                    (f[i+1][newr][newst]+=f[i][r][st])%=MOD;
                }
            }
        }
    }
    long long ans=f[len][0][0];
    (ans+=f[len][0][1])%=MOD;
    return ans;
}

int check(const string& a)
{
    for(int i=0; i<a.size(); ++i)
    {
        if (i%2==1&&a[i]-'0'!=d) return 0;
        if (i%2==0&&a[i]-'0'==d) return 0;
    }
    return stoll(a)%m==0;
}

int main()
{
    //freopen("INPUT.TXT","r",stdin);
//    freopen("OUTPUT.TXT","w",stdout);
    cin>>m>>d>>a>>b;
    long ans=(calc(b)-calc(a)+MOD)%MOD;
    ans+=check(a);
    ans%=MOD;
    cout<<ans;
    return 0;
}


#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#define ft(i,a,b) for(int i=a; i<=b; ++i)

using namespace std;

long long f[2000][2000][4],m,d;
const int mod = 100;
string a,b;

long long calc(const string &a)
{
    int len=a.size();
    memset(f,0,sizeof(f));
    ft(x,1,9) {
        if (x==d) continue;
        int st=1;
        int de=a[1]-'0';
        if (x>a[0]-'0') st=2;
        if (x<a[0]-'0') st=0;
        f[1][x%m][st]++;
    }
    ft(i,1,len)
    {
        ft(r,0,m-1)
        {
            ft(st,0,2)
            {
                if (f[i][r][st]==0) continue;
                ft(x,0,9)
                {
                    if (i % 2 == 0 && x == d) {
                        continue;
                    }
                    if (i % 2 == 1 && x != d) {
                        continue;
                    }
                    int newst=st;
                    int newr=(r*10+x)%m;
                    if (newst==1)
                    {
                        if (x>a[i]-'0') newst=2;
                        if (x<a[i]-'0') newst=0;
                        if (x==a[i]-'0') newst=1;
                    }
                    f[i+1][newr][newst]+=f[i][r][st];
                }
            }
        }
    }
    long long ans=0;
    ans=f[len][0][1]+f[len][0][0];
    return ans;
}

int check(const string& a)
{
    for(int i=0; i<a.size(); ++i)
    {
        if (i%2==1&&a[i]!=d) return 0;
    }
}

int main()
{
//    freopen("INPUT.TXT","r",stdin);
//    freopen("OUTPUT.TXT","w",stdout);
    cin>>m>>d>>a>>b;
    cout<<calc(b)-calc(a)+check(a);
    return 0;
}


#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#define ft(i,a,b) for(int i=a; i<=b; ++i)

using namespace std;

long f[2000][2000][4],m,d;
const int mod = 100;
string a,b;

int calc(string a)
{
    string n='0'+a;
    int len=n.size()-1;
    memset(f,0,sizeof(f));
    ft(x,1,9) {
        if (x==d) continue;
        int st=1;
        int de=n[1]-'0';
        if (x>n[1]-'0') st=2;
        if (x<n[1]-'0') st=0;
        f[1][x%m][st]++;
    }
    ft(i,1,len)
    {
        ft(r,0,m-1)
        {
            ft(st,0,2)
            {
                if (f[i][r][st]==0) continue;
                ft(x,0,9)
                {
                    if (i % 2 == 0 && x == d) {
                        continue;
                    }
                    if (i % 2 == 1 && x != d) {
                        continue;
                    }
                    int newst=st;
                    int newr=(r*10+x)%m;
                    if (newst==1)
                    {
                        if (x>n[i]-'0') newst=2;
                        if (x<n[i]-'0') newst=0;
                        if (x==n[i]-'0') newst=1;
                    }
                    f[i+1][newr][newst]+=f[i][r][st];
                }
            }
        }
    }
    int ans=0;
    ans=f[len][0][1]+f[len][0][0];
    return ans;
}

int check(const string& a)
{
    for(int i=0; i<a.size(); ++i)
    {
        if (i%2==1&&a[i]!=d) return 0;
    }
}

int main()
{
//    freopen("INPUT.TXT","r",stdin);
//    freopen("OUTPUT.TXT","w",stdout);
    cin>>m>>d>>a>>b;
    cout<<calc(b)-calc(a)+check(a);
    return 0;
}


#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#define ft(i,a,b) for(int i=a; i<=b; ++i)

using namespace std;

long long f[2010][2010][4],m,d;
const long MOD = 1000000007;
string a,b;

long long calc(const string &a)
{
    int len=a.size();
    memset(f,0,sizeof(f));
    ft(x,1,9) {
        if (x==d) continue;
        int st=1;
        if (x>a[0]-'0') st=2;
        if (x<a[0]-'0') st=0;
        f[1][x%m][st]++;
    }
    ft(i,1,len)
    {
        ft(r,0,m-1)
        {
            ft(st,0,2)
            {
                if (f[i][r][st]==0) continue;
                ft(x,0,9)
                {
                    if (i % 2 == 0 && x == d) {
                        continue;
                    }
                    if (i % 2 == 1 && x != d) {
                        continue;
                    }
                    int newst=st;
                    int newr=(r*10+x)%m;
                    if (newst==1)
                    {
                        if (x>a[i]-'0') newst=2;
                        if (x<a[i]-'0') newst=0;
                        if (x==a[i]-'0') newst=1;
                    }
                    (f[i+1][newr][newst]+=f[i][r][st])%=MOD;
                }
            }
        }
    }
    long long ans=f[len][0][0];
    (ans+=f[len][0][1])%=MOD;
    return ans;
}

int check(const string& a)
{
    for(int i=0; i<a.size(); ++i)
    {
        if (i%2==1&&a[i]-'0'!=d) return 0;
        if (i%2==0&&a[i]-'0'==d) return 0;
    }
    return stoll(a)%m==0;
}

int main()
{
    //freopen("INPUT.TXT","r",stdin);
//    freopen("OUTPUT.TXT","w",stdout);
    cin>>m>>d>>a>>b;
    long ans=(calc(b)-calc(a)+MOD)%MOD;
    ans+=check(a);
    ans%=MOD;
    cout<<ans;
    return 0;
}


#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#define ft(i,a,b) for(int i=a; i<=b; ++i)

using namespace std;

long long f[2000][2000][4],m,d;
const long MOD = 1000000007;
string a,b;

long long calc(const string &a)
{
    int len=a.size();
    memset(f,0,sizeof(f));
    ft(x,1,9) {
        if (x==d) continue;
        int st=1;
        if (x>a[0]-'0') st=2;
        if (x<a[0]-'0') st=0;
        f[1][x%m][st]++;
    }
    ft(i,1,len)
    {
        ft(r,0,m-1)
        {
            ft(st,0,2)
            {
                if (f[i][r][st]==0) continue;
                ft(x,0,9)
                {
                    if (i % 2 == 0 && x == d) {
                        continue;
                    }
                    if (i % 2 == 1 && x != d) {
                        continue;
                    }
                    int newst=st;
                    int newr=(r*10+x)%m;
                    if (newst==1)
                    {
                        if (x>a[i]-'0') newst=2;
                        if (x<a[i]-'0') newst=0;
                        if (x==a[i]-'0') newst=1;
                    }
                    (f[i+1][newr][newst]+=f[i][r][st])%=MOD;
                }
            }
        }
    }
    long long ans=f[len][0][0];
    (ans+=f[len][0][1])%=MOD;
    return ans;
}

int check(const string& a)
{
    for(int i=0; i<a.size(); ++i)
    {
        if (i%2==1&&a[i]!=d) return 0;
        if (i%2==0&&a[i]==d) return 0;
    }
    return 1;
}

int main()
{
//    freopen("INPUT.TXT","r",stdin);
//    freopen("OUTPUT.TXT","w",stdout);
    cin>>m>>d>>a>>b;
    long ans=(calc(b)-calc(a)+MOD)%MOD;
    ans+=check(a);
    ans%=MOD;
    cout<<ans;
    return 0;
}


#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#define ft(i,a,b) for(int i=a; i<=b; ++i)

using namespace std;

long long f[2010][2010][4],m,d;
const long MOD = 1000000007;
string a,b;

long long calc(const string &a)
{
    int len=a.size();
    memset(f,0,sizeof(f));
    ft(x,1,9) {
        if (x==d) continue;
        int st=1;
        if (x>a[0]-'0') st=2;
        if (x<a[0]-'0') st=0;
        f[1][x%m][st]++;
    }
    ft(i,1,len)
    {
        ft(r,0,m-1)
        {
            ft(st,0,2)
            {
                if (f[i][r][st]==0) continue;
                ft(x,0,9)
                {
                    if (i % 2 == 0 && x == d) {
                        continue;
                    }
                    if (i % 2 == 1 && x != d) {
                        continue;
                    }
                    int newst=st;
                    int newr=(r*10+x)%m;
                    if (newst==1)
                    {
                        if (x>a[i]-'0') newst=2;
                        if (x<a[i]-'0') newst=0;
                        if (x==a[i]-'0') newst=1;
                    }
                    (f[i+1][newr][newst]+=f[i][r][st])%=MOD;
                }
            }
        }
    }
    long long ans=f[len][0][0];
    (ans+=f[len][0][1])%=MOD;
    return ans;
}

int check(const string& a)
{
    for(int i=0; i<a.size(); ++i)
    {
        if (i%2==1&&a[i]-'0'!=d) return 0;
        if (i%2==0&&a[i]-'0'==d) return 0;
    }
    int f=a[0]-'0';
    for(int i=1; i<a.size(); ++i)
    {
        f=(f*10+a[i]-'0')%m;
    }
    return f==0;
}

int main()
{
    //freopen("INPUT.TXT","r",stdin);
//    freopen("OUTPUT.TXT","w",stdout);
    cin>>m>>d>>a>>b;
    long ans=(calc(b)-calc(a)+MOD)%MOD;
    ans+=check(a);
    ans%=MOD;
    cout<<ans;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

//#define int long long
//#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;
const int maxN = 2010;

int pow10[maxN];

int get(string& s, int m, int d) {
    int n = s.size();
    vector<vector<vector<int>>> dp(2, vector<vector<int>>(n, vector<int>(m)));
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = s[i] - '0';
    }

    for (int i = 1; i <= a[0]; i++) {
        if (i == d) continue;
        dp[i == a[0]][0][pow10[n - 1] * i % m]++;
    }

    for (int i = 1; i < n; i++) {
        for (int x = 1; x < 10; x++) {
            if ((i % 2 && x != d) || (i % 2 == 0 && x == d)) continue;
            dp[0][i][pow10[n - i - 1] * x % m]++;
        }
        for (int j = 0; j < m; j++) {
            for (int x = 0; x < 10; x++) {
                int last = (j - pow10[n - i - 1] * x % m + m) % m;

                if ((i % 2 && x != d) || (i % 2 == 0 && x == d)) continue;
                dp[0][i][j] += dp[0][i - 1][last];

                if (x < a[i]) dp[0][i][j] += dp[1][i - 1][last];
                if (x == a[i]) dp[1][i][j] += dp[1][i - 1][last];

                dp[0][i][j] %= MOD;
                dp[1][i][j] %= MOD;
            }
        }
    }

    return (dp[0][n - 1][0] + dp[1][n - 1][0]) % MOD;
}

bool check(string s, int m, int d) {
    int ost = 0;
    reverse(all(s));
    for (int i = 0; i < s.size(); i++) {
        ost = (ost + pow10[i] * (s[i] - '0') % m) % m;
        if ((i % 2 && s[i] - '0' == d) || (i % 2 == 0 && s[i] - '0' != d)) return false;
    }
    return ost == 0;
}

void solve() {
    int m, d;
    cin >> m >> d;
    pow10[0] = 1;
    for (int i = 1; i < maxN; i++) {
        pow10[i] = pow10[i - 1] * 10 % m;
    }

    string a, b;
    cin >> a >> b;
    cout << ((get(b, m, d) - get(a, m, d) + MOD) % MOD + check(a, m, d)) % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(12);
    cout << fixed;
    solve();
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define int long long
//#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;
const int maxN = 2010;

int pow10[maxN];

int get(string& s, int m, int d) {
    int n = s.size();
    vector<vector<vector<int>>> dp(2, vector<vector<int>>(n, vector<int>(m)));
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = s[i] - '0';
    }

    for (int i = 1; i <= a[0]; i++) {
        if (i == d) continue;
        dp[i == a[0]][0][pow10[n - 1] * i % m]++;
    }

    for (int i = 1; i < n; i++) {
        for (int x = 1; x < 10; x++) {
            if ((i % 2 && x != d) || (i % 2 == 0 && x == d)) continue;
            dp[0][i][pow10[n - i - 1] * x % m]++;
        }
        for (int j = 0; j < m; j++) {
            for (int x = 0; x < 10; x++) {
                int last = (j - pow10[n - i - 1] * x % m + m) % m;

                if ((i % 2 && x != d) || (i % 2 == 0 && x == d)) continue;
                dp[0][i][j] += dp[0][i - 1][last];

                if (x < a[i]) dp[0][i][j] += dp[1][i - 1][last];
                if (x == a[i]) dp[1][i][j] += dp[1][i - 1][last];

                dp[0][i][j] %= MOD;
                dp[1][i][j] %= MOD;
            }
        }
    }

    return (dp[0][n - 1][0] + dp[1][n - 1][0]) % MOD;
}

bool check(string s, int m, int d) {
    int ost = 0;
    reverse(all(s));
    for (int i = 0; i < s.size(); i++) {
        ost = (ost + pow10[i] * (s[i] - '0') % m) % m;
        if ((i % 2 && s[i] - '0' == d) || (i % 2 == 0 && s[i] - '0' != d)) return false;
    }
    return ost == 0;
}

void solve() {
    int m, d;
    cin >> m >> d;
    pow10[0] = 1;
    for (int i = 1; i < maxN; i++) {
        pow10[i] = pow10[i - 1] * 10 % m;
    }

    string a, b;
    cin >> a >> b;
    cout << ((get(b, m, d) - get(a, m, d) + MOD) % MOD + check(a, m, d)) % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(12);
    cout << fixed;
    solve();
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define int long long
//#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;
const int maxN = 2010;

int pow10[maxN];

int get(string& s, int m, int d) {
    int n = s.size();
    vector<vector<vector<int>>> dp(2, vector<vector<int>>(n, vector<int>(m)));
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = s[i] - '0';
    }

    for (int i = 1; i <= a[0]; i++) {
        if (i == d) continue;
        dp[i == a[0]][0][pow10[n - 1] * i % m]++;
    }

    for (int i = 1; i < n; i++) {
        for (int x = 1; x < 10; x++) {
            if ((i % 2 && x != d) || (i % 2 == 0 && x == d)) continue;
            dp[0][i][pow10[n - i - 1] * x % m]++;
        }
        for (int j = 0; j < m; j++) {
            for (int x = 0; x < 10; x++) {
                int last = (j - pow10[n - i - 1] * x % m + m) % m;

                if ((i % 2 && x != d) || (i % 2 == 0 && x == d)) continue;
                dp[0][i][j] += dp[0][i - 1][last];

                if (x < a[i]) dp[0][i][j] += dp[1][i - 1][last];
                if (x == a[i]) dp[1][i][j] += dp[1][i - 1][last];

                dp[0][i][j] %= MOD;
                dp[1][i][j] %= MOD;
            }
        }
    }

    return (dp[0][n - 1][0] + dp[1][n - 1][0]) % MOD;
}

bool check(string s, int m, int d) {
    int ost = 0;
    reverse(all(s));
    for (int i = 0; i < s.size(); i++) {
        ost = (ost + pow10[i] * (s[i] - '0') % m) % m;
        if ((i % 2 && s[i] - '0' != d) || (i % 2 == 0 && s[i] - '0' == d)) continue;
    }
    return ost == 0;
}

void solve() {
    int m, d;
    cin >> m >> d;
    pow10[0] = 1;
    for (int i = 1; i < maxN; i++) {
        pow10[i] = pow10[i - 1] * 10 % m;
    }

    string a, b;
    cin >> a >> b;
    cout << ((get(b, m, d) - get(a, m, d) + MOD) % MOD + check(a, m, d)) % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(12);
    cout << fixed;
    solve();
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define int long long
//#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;
const int maxN = 2010;

int pow10[maxN];

int get(string& s, int m, int d) {
    int n = s.size();
    vector<vector<vector<int>>> dp(2, vector<vector<int>>(n, vector<int>(m)));
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = s[i] - '0';
    }

    for (int i = 1; i <= a[0]; i++) {
        if (i == d) continue;
        dp[i == a[0]][0][pow10[n - 1] * i % m]++;
    }

    for (int i = 1; i < n; i++) {
        for (int x = 1; x < 10; x++) {
            if ((i % 2 && x != d) || (i % 2 == 0 && x == d)) continue;
            dp[0][i][pow10[n - i - 1] * x % m]++;
        }
        for (int j = 0; j < m; j++) {
            for (int x = 0; x < 10; x++) {
                int last = (j - pow10[n - i - 1] * x % m + m) % m;

                if ((i % 2 && x != d) || (i % 2 == 0 && x == d)) continue;
                dp[0][i][j] += dp[0][i - 1][last];

                if (x < a[i]) dp[0][i][j] += dp[1][i - 1][last];
                if (x == a[i]) dp[1][i][j] += dp[1][i - 1][last];

                dp[0][i][j] %= MOD;
                dp[1][i][j] %= MOD;
            }
        }
    }

    return (dp[0][n - 1][0] + dp[1][n - 1][0]) % MOD;
}

bool check(string s, int m, int d) {
    int ost = 0;
    for (int i = 0; i < s.size(); i++) {
        ost = (ost + pow10[s.size() - i - 1] * (s[i] - '0') % m) % m;
        if ((i % 2 && s[i] - '0' != d) || (i % 2 == 0 && s[i] - '0' == d)) return false;
    }
    return ost == 0;
}

void solve() {
    int m, d;
    cin >> m >> d;
    pow10[0] = 1;
    for (int i = 1; i < maxN; i++) {
        pow10[i] = pow10[i - 1] * 10 % m;
    }

    string a, b;
    cin >> a >> b;
    cout << ((get(b, m, d) - get(a, m, d) + MOD) % MOD + check(a, m, d)) % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(12);
    cout << fixed;
    solve();
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define int long long
//#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;
const int maxN = 2010;

int pow10[maxN];

int get(string& s, int m, int d) {
    int n = s.size();
    vector<vector<vector<int>>> dp(2, vector<vector<int>>(n, vector<int>(m)));
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = s[i] - '0';
    }

    for (int i = 1; i <= a[0]; i++) {
        if (i == d) continue;
        dp[i == a[0]][0][pow10[n - 1] * i % m]++;
    }

    for (int i = 1; i < n; i++) {
        for (int x = 1; x < 10; x++) {
            if ((i % 2 && x != d) || (i % 2 == 0 && x == d)) continue;
            dp[0][i][pow10[n - i - 1] * x % m]++;
        }
        for (int j = 0; j < m; j++) {
            for (int x = 0; x < 10; x++) {
                int last = (j - pow10[n - i - 1] * x % m + m) % m;

                if ((i % 2 && x != d) || (i % 2 == 0 && x == d)) continue;
                dp[0][i][j] += dp[0][i - 1][last];

                if (x < a[i]) dp[0][i][j] += dp[1][i - 1][last];
                if (x == a[i]) dp[1][i][j] += dp[1][i - 1][last];

                dp[0][i][j] %= MOD;
                dp[1][i][j] %= MOD;
            }
        }
    }

    return (dp[0][n - 1][0] + dp[1][n - 1][0]) % MOD;
}

bool check(string s, int m, int d) {
    int ost = 0;
    for (int i = 0; i < s.size(); i++) {
        ost = (ost + pow10[i] * (s[i] - '0') % m) % m;
        if ((i % 2 && s[i] - '0' != d) || (i % 2 == 0 && s[i] - '0' == d)) return false;
    }
    return ost == 0;
}

void solve() {
    int m, d;
    cin >> m >> d;
    pow10[0] = 1;
    for (int i = 1; i < maxN; i++) {
        pow10[i] = pow10[i - 1] * 10 % m;
    }

    string a, b;
    cin >> a >> b;
    cout << ((get(b, m, d) - get(a, m, d) + MOD) % MOD + check(a, m, d)) % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(12);
    cout << fixed;
    solve();
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define int long long
//#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;
const int maxN = 2010;

int pow10[maxN];

int get(string& s, int m, int d) {
    int n = s.size();
    vector<vector<vector<int>>> dp(2, vector<vector<int>>(n, vector<int>(m)));
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = s[i] - '0';
    }

    for (int i = 1; i <= a[0]; i++) {
        if (i == d) continue;
        dp[i == a[0]][0][pow10[n - 1] * i % m]++;
    }

    for (int i = 1; i < n; i++) {
        for (int x = 1; x < 10; x++) {
            if ((i % 2 && x != d) || (i % 2 == 0 && x == d)) continue;
            dp[0][i][pow10[n - i - 1] * x % m]++;
        }
        for (int j = 0; j < m; j++) {
            for (int x = 0; x < 10; x++) {
                int last = (j - pow10[n - i - 1] * x % m + m) % m;

                if ((i % 2 && x != d) || (i % 2 == 0 && x == d)) continue;
                dp[0][i][j] += dp[0][i - 1][last];

                if (x < a[i]) dp[0][i][j] += dp[1][i - 1][last];
                if (x == a[i]) dp[1][i][j] += dp[1][i - 1][last];

                dp[0][i][j] %= MOD;
                dp[1][i][j] %= MOD;
            }
        }
    }

    return (dp[0][n - 1][0] + dp[1][n - 1][0]) % MOD;
}

bool check(string s, int m, int d) {
    int ost = 0;
    reverse(all(s));
    for (int i = 0; i < s.size(); i++) {
        ost = (ost + pow10[i] * (s[i] - '0') % m) % m;
        if ((i % 2 && s[i] - '0' != d) || (i % 2 == 0 && s[i] - '0' == d)) return false;
    }
    return ost == 0;
}

void solve() {
    int m, d;
    cin >> m >> d;
    pow10[0] = 1;
    for (int i = 1; i < maxN; i++) {
        pow10[i] = pow10[i - 1] * 10 % m;
    }

    string a, b;
    cin >> a >> b;
    cout << ((get(b, m, d) - get(a, m, d) + MOD) % MOD + check(a, m, d)) % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(12);
    cout << fixed;
    solve();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)

const int L=1e6+7;
int m, d, mod = 1e9+7;
string a, b;
int lena, lenb;
ll dp[2002][2002][2][2][2];
ll solve(int sofar,int i, int gr,int fl, int cur)
{
	ll ans = 0;
	if(i > lenb)return 0;
	sofar%=m;
	int tr = gr, tl = fl ;
	if(i == lenb)
	{
		if(sofar == 0 && gr && fl)return 1LL;
		return 0LL;
	}
	if(dp[sofar][i][gr][fl][cur] != -1)return dp[sofar][i][gr][fl][cur];
	if(cur&1)
	{
		if(d < b[i] - '0')tl = 1;
		if(!fl && d > b[i] - '0')return 0LL;
		if(!gr && d < a[i] - '0')return 0LL;
		if(d > (a[i]-'0'))tr = 1;
		ans = (ans%mod + solve(sofar*10+d, i + 1, tr,tl, 1 - cur)%mod)%mod;
		ans %= mod;
	}
	else
	{
		FOR(j,0,10)
		{
			tl = fl, tr = gr;
			if(!fl && j > b[i]-'0')continue;
			if(!gr && j < a[i]-'0')continue;
			if(j == d)continue;
			if(j>a[i]-'0')tr = 1;
			if(j<b[i] - '0')tl = 1;
			ans = (ans%mod +  solve((sofar*10)+j, i + 1, tr,tl, 1-cur)%mod)%mod;
		}
	}
	return dp[sofar][i][gr][fl][cur] = ans;
}
int main()
{
		ios_base::sync_with_stdio(false);
	 	cin.tie(NULL);
	 	string ta = "";
	 	cin >> m >> d;
	 	cin >> ta >> b;
	 	lena = ta.length();
	 	lenb = b.length();
	 	FOR(i,0,2001)FOR(j,0,2001)FOR(k,0,2)FOR(l,0,2)FOR(z,0,2)dp[i][j][k][l][z]=-1;
	 	a = "";
	 	FOR(i,0,lenb-lena)a+="0";
	 	a += ta;
	 	cout<<solve(0,0,0,0,0);
		return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)

const int L=1e6+7;
int m, d, mod = 1e9+7;
string a, b;
int lena, lenb;
ll dp[2002][2002][2][2][2];
ll solve(int sofar,int i, int gr,int fl, int cur)
{
	ll ans = 0;
	if(i > lenb)return 0;
	sofar%=m;
	int tr = gr, tl = fl ;
	if(i == lenb)
	{
		if(sofar == 0 && gr && fl)return 1LL;
		return 0LL;
	}
	if(dp[sofar][i][gr][fl][cur] != -1)return dp[sofar][i][gr][fl][cur];
	if(cur&1)
	{
		if(d < b[i] - '0')tl = 1;
		if(!fl && d > b[i] - '0')return 0LL;
		if(!gr && d < a[i] - '0')return 0LL;
		if(d > (a[i]-'0'))tr = 1;
		ans = (ans%mod + solve(sofar*10+d, i + 1, tr,tl, 1 - cur)%mod)%mod;
		ans %= mod;
	}
	else
	{
		FOR(j,0,10)
		{
			tl = fl, tr = gr;
			if(!fl && j > b[i]-'0')continue;
			if(!gr && j < a[i]-'0')continue;
			if(j == d)continue;
			if(j>a[i]-'0')tr = 1;
			if(j<b[i] - '0')tl = 1;
			ans = (ans%mod +  solve((sofar*10)+j, i + 1, tr,tl, 1-cur)%mod)%mod;
		}
	}
	return dp[sofar][i][gr][fl][cur] = ans;
}
int main()
{
		ios_base::sync_with_stdio(false);
	 	cin.tie(NULL);
	 	string ta = "";
	 	cin >> m >> d;
	 	cin >> ta >> b;
	 	lena = ta.length();
	 	lenb = b.length();
	 	FOR(i,0,2001)FOR(j,0,2001)FOR(k,0,2)FOR(l,0,2)FOR(z,0,2)dp[i][j][k][l][z]=-1;
	 	a = "";
	 	FOR(i,0,lenb-lena)a+="0";
	 	a += ta;
	 	ll tmp = solve(0,0,0,0,0);
	 	int f =0;
	 	for (int i = 1; i < lena; i += 2)
	 	{
	 		if(ta[i]-'0' != d)
	 		{
	 			f = 1;
	 			break;
	 		}
	 	}
	 	if(!f)tmp++;
	 	for (int i = 1; i < lenb; i += 2)
	 	{
	 		if(b[i]-'0' != d)
	 		{
	 			f = 1;
	 			break;
	 		}
	 	}
	 	if(!f && ta != b)tmp++;
	 	cout<<tmp%mod;
		return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)

const int L=1e6+7;
int m, d, mod = 1e9+7;
string a, b;
int lena, lenb;
ll dp[2002][2002][2][2][2];
ll solve(int sofar,int i, int gr,int fl, int cur)
{
	ll ans = 0;
	if(i > lenb)return 0;
	// debug(i,num,sofar);
	sofar%=m;
	// debug(m);
	if(i == lenb)
	{
		if(sofar == 0 && gr && fl)
		{
		// debug(i,num, gr,sofar);
			return 1LL;
		}
		return 0LL;
	}
	if(dp[sofar][i][gr][fl][cur] != -1)return dp[sofar][i][gr][fl][cur];
	if(cur&1)
	{
		if(d > (a[i]-'0'))gr = 1;
		if(d < b[i] - '0')fl = 1;
		if(!fl && d > b[i] - '0')return 0;
		ans += solve(sofar*10+d, i + 1, gr,fl, 1 - cur);
		ans %= m;
	}
	else
	{
		int f = gr;
		FOR(j,a[i]-'0', 10)
		{
			if(!fl && j > b[i]-'0')break;
			if(j == d)continue;
			if(j>a[i]-'0')gr = 1;
			if(j < b[i] - '0' && fl == 0)
				ans += solve((sofar*10)+j, i + 1, gr,1, 1-cur);
			else
				ans += solve((sofar*10)+j, i + 1, gr,fl, 1-cur);
			ans %= mod;
		}
		if(f)
		{
			RFOR(j,a[i]-'0'-1,0)
			{
				if(!fl && j > b[i]-'0')break;
				if(j == d)continue;
				if(j < b[i] - '0' && fl == 0)
					ans += solve((sofar*10)+j, i + 1, gr,1, 1-cur);
				else
					ans += solve((sofar*10)+j, i + 1, gr,fl, 1-cur);
				// ans += solve((sofar*10)+j, i + 1, gr, 1-cur,num*10+j);
				ans %= mod;
			}
		}
	}
	return dp[sofar][i][gr][fl][cur] = ans;
}
int main()
{
		ios_base::sync_with_stdio(false);
	 	cin.tie(NULL);
	 	string ta = "";
	 	cin >> m >> d;
	 	cin >> ta >> b;
	 	lena = ta.length();
	 	lenb = b.length();
	 	FOR(i,0,2001)FOR(j,0,2001)FOR(k,0,2)FOR(l,0,2)FOR(z,0,2)dp[i][j][k][l][z]=-1;
	 	a = "";
	 	FOR(i,0,lenb-lena)a+="0";
	 	a += ta;
	 	cout<<solve(0,0,0,0,0);
		return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)

const int L=1e6+7;
int m, d, mod = 1e9+7;
string a, b;
int lena, lenb;
ll dp[2002][2002][2][2];
ll solve(int sofar,int i, int gr, int cur)
{
	ll ans = 0;
	if(i > lenb)return 0;
	// debug(i,num);
	if(dp[sofar][i][gr][cur] != -1)return dp[sofar][i][gr][cur];
	if(i == lenb)
	{
		// debug(i,num, gr,sofar);
		if(sofar%m == 0 && gr)return 1LL;
		return 0LL;
	}
	if(cur&1)
	{
		sofar*=10;
		sofar+=d;
		sofar%=m;
		if(d > a[i]-'0')gr = 1;
		ans += solve(sofar*10+d, i + 1, gr, 1 - cur);
		ans %= m;
	}
	else
	{
		int f = gr;
		FOR(j,a[i]-'0', 10)
		{
			if(j == d)continue;
			if(j>a[i]-'0')gr = 1;
			ans += solve(((sofar*10)+j)%m, i + 1, gr, 1-cur);
			ans %= mod;
		}
		if(f)
		{
			RFOR(j,a[i]-'0'-1,0)
			{
				if(j == d)continue;
				ans += solve(((sofar*10)+j)%m, i + 1, gr, 1-cur);
				ans %= mod;
			}
		}
	}
	return dp[sofar][i][gr][cur] = ans;
}
int main()
{
		ios_base::sync_with_stdio(false);
	 	cin.tie(NULL);
	 	string ta = "";
	 	cin >> m >> d;
	 	cin >> ta >> b;
	 	lena = ta.length();
	 	lenb = b.length();
	 	FOR(i,0,2001)FOR(j,0,2001)FOR(k,0,2)FOR(l,0,2)dp[i][j][k][l]=-1;
	 	a = "";
	 	FOR(i,0,lenb-lena)a+="0";
	 	a += ta;
	 	cout<<solve(0,0,0,0);
		return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)

const int L=1e6+7;
int m, d, mod = 1e9+7;
string a, b;
int lena, lenb;
ll dp[2002][2002][2][2];
ll solve(int sofar,int i, int gr, int cur)
{
	ll ans = 0;
	if(i > lenb)return 0;
	if(dp[sofar][i][gr][cur] != -1)return dp[sofar][i][gr][cur];
	if(i == lenb)
	{
		if(sofar == 0 && gr)return 1LL;
		return 0LL;
	}
	if(cur&1)
	{
		sofar*=10;
		sofar+=d;
		sofar%=m;
		if(d > a[i]-'0')gr = 1;
		ans += solve(sofar, i + 1, gr, 1 - cur);
		ans %= m;
	}
	else
	{
		int f = gr;
		FOR(j,a[i]-'0', 10)
		{
			if(j == d)continue;
			if(j>a[i]-'0')gr = 1;
			ans += solve(((sofar*10)+j)%m, i + 1, gr, 1-cur);
			ans %= mod;
		}
		if(f)
		{
			RFOR(j,a[i]-'0'-1,0)
			{
				if(j == d)continue;
				ans += solve(((sofar*10)+j)%m, i + 1, gr, 1-cur);
				ans %= mod;
			}
		}
	}
	return dp[sofar][i][gr][cur] = ans;
}
int main()
{
		ios_base::sync_with_stdio(false);
	 	cin.tie(NULL);
	 	string ta = "";
	 	cin >> m >> d;
	 	cin >> ta >> b;
	 	lena = ta.length();
	 	lenb = b.length();
	 	FOR(i,0,2001)FOR(j,0,2001)FOR(k,0,2)FOR(l,0,2)dp[i][j][k][l]=-1;
	 	a = "";
	 	FOR(i,0,lenb-lena)a+="0";
	 	a += ta;
	 	cout<<solve(0,0,0,0);
		return 0;
}