#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T amax(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
const int N = 2005;
int n, m, d;
string p, q;
int a[N], b[N];
int dp[N][N][2][2];
int calc(int id, int rem, int aflag, int bflag) {
  if (id == n) {
    return (rem == 0);
  }
  int& ans = dp[id][rem][aflag][bflag];
  if (ans != -1) {
    return ans;
  }
  ans = 0;
  if (aflag && bflag) {
    for (int x = 0; x < 10; x++) {
      if ((id % 2 && x != d) || (id % 2 == 0 && x == d)) {
        continue;
      }
      ans = (ans + calc(id + 1, (10 * rem + x) % m, 1, 1)) % M;
    }
  } else if (aflag && bflag == 0) {
    for (int x = 0; x < b[id] + 1; x++) {
      if ((id % 2 && x != d) || (id % 2 == 0 && x == d)) {
        continue;
      }
      ans = (ans + calc(id + 1, (10 * rem + x) % m, 1, x != b[id])) % M;
    }
  } else if (aflag == 0 && bflag) {
    for (int x = a[id]; x < 10; x++) {
      if ((id % 2 && x != d) || (id % 2 == 0 && x == d)) {
        continue;
      }
      ans = (ans + calc(id + 1, (10 * rem + x) % m, x != a[id], 1)) % M;
    }
  } else {
    for (int x = a[id]; x < b[id] + 1; x++) {
      if ((id % 2 && x != d) || (id % 2 == 0 && x == d)) {
        continue;
      }
      ans =
          (ans + calc(id + 1, (10 * rem + x) % m, x != a[id], x != b[id])) % M;
    }
  }
  return ans;
}
void solve() {
  memset(dp, -1, sizeof(dp));
  cin >> m >> d >> p >> q;
  n = (int)((p).size());
  for (int i = 0; i < n; i++) {
    a[i] = p[i] - '0';
    b[i] = q[i] - '0';
  }
  cout << calc(0, 0, 0, 0);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
