#include <bits/stdc++.h>
using namespace std;
namespace NYAN {
const int MAXN = 1e6, N = MAXN + 6, SIGMA = 26, MOD = 1e9 + 7;
char a[N], b[N], *key;
int n;
long long cnt[SIGMA], fac[N], inv[N], prodinv[N];
long long calc() {
  long long res = 0;
  for (int i = 0; i <= n; ++i) {
    if (i == n) {
      res = (res + 1) % MOD;
      break;
    }
    int e = key[i] - 'a';
    assert(e < SIGMA);
    long long cur = fac[n - i - 1];
    for (int d = 0; d < SIGMA; ++d)
      if (cnt[d]) {
        cur = (cur * prodinv[cnt[d]]) % MOD;
      }
    for (int c = 0; c < e; ++c)
      if (cnt[c] > 0) {
        res = (res + cur * cnt[c] % MOD) % MOD;
      }
    if (cnt[e] > 0)
      --cnt[e];
    else
      break;
  }
  return res;
}
void main() {
  scanf("%s%s", a, b);
  n = strlen(a);
  fac[0] = fac[1] = 1;
  inv[1] = prodinv[1] = 1;
  for (int i = 2; i <= n; ++i) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
    prodinv[i] = prodinv[i - 1] * inv[i] % MOD;
  }
  for (int i = 0; i < SIGMA; ++i) cnt[i] = 0;
  for (int i = 0; i < n; ++i) {
    ++cnt[a[i] - 'a'];
  }
  --b[n - 1];
  key = b;
  long long high = calc();
  for (int i = 0; i < SIGMA; ++i) cnt[i] = 0;
  for (int i = 0; i < n; ++i) {
    ++cnt[a[i] - 'a'];
  }
  key = a;
  long long low = calc();
  long long ans = (high - low + MOD) % MOD;
  cout << ans << endl;
}
}  // namespace NYAN
int main() {
  NYAN::main();
  return 0;
}
