#include <bits/stdc++.h>
using namespace std;
const long long tintaodimayngulam = 1e9 + 7;
long long dp[2005][2005][2][2];
long long n, d, m;
string a, b;
long long f(long long i, long long mod1, long long flags1, long long flags2) {
  if (i == n + 1) return (mod1 == 0);
  if (dp[i][mod1][flags1][flags2] != -1) return dp[i][mod1][flags1][flags2];
  long long l = a[i] - 48, r = b[i] - 48, ok1, ok2;
  if (flags1) l = 0;
  if (flags2) r = 9;
  long long ans = 0;
  if (i % 2 == 0) {
    if (d < l || d > r) return 0;
    if (d == l && !flags1)
      return dp[i][mod1][flags1][flags2] = f(i + 1, (mod1 * 10 + d) % m, 0, 1);
    else if (d == r && !flags2)
      return dp[i][mod1][flags1][flags2] = f(i + 1, (mod1 * 10 + d) % m, 1, 0);
    else
      return dp[i][mod1][flags1][flags2] = f(i + 1, (mod1 * 10 + d) % m, 1, 1);
  }
  for (int p = l; p <= r; p++)
    if (d != p) {
      ok1 = 1;
      ok2 = 1;
      if (!flags1 && p == l) ok1 = 0;
      if (!flags2 && p == r) ok2 = 0;
      ans = (ans + f(i + 1, (mod1 * 10 + p) % m, ok1, ok2)) % tintaodimayngulam;
    }
  return dp[i][mod1][flags1][flags2] = ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (ifstream(".inp")) {
    freopen(".inp", "r", stdin);
    freopen(".out", "w", stdout);
  }
  cin >> m >> d;
  cin >> a >> b;
  n = b.length();
  while (a.length() < n) a = '0' + a;
  memset(dp, 255, sizeof(dp));
  a = '.' + a;
  b = '.' + b;
  cout << f(1, 0, 0, 0) << '\n';
  return 0;
}
