#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long cnt[30], tmp[30];
long long f[1000005];
long long Inv[1000005];
long long lena;
void init() {
  f[0] = Inv[0] = f[1] = Inv[1] = 1;
  for (long long i = 2; i <= 1000003; i++) f[i] = f[i - 1] * i % mod;
  for (long long i = 2; i <= 1000003; i++)
    Inv[i] = (mod - mod / i) * Inv[mod % i] % mod;
  for (long long i = 1; i <= 1000003; i++) Inv[i] = Inv[i] * Inv[i - 1] % mod;
}
long long C(long long n, long long m) {
  long long ans = f[n] * Inv[m] % mod * Inv[n - m] % mod;
  return ans;
}
long long solve(string x) {
  long long ans = 0;
  int len = x.size();
  long long cur = f[len];
  for (int i = 0; i < 26; i++) cur = cur * Inv[cnt[i]] % mod;
  for (int i = 0; i < 26; i++) tmp[i] = cnt[i];
  int L = lena;
  for (int i = 0; i < len; i++) {
    for (int j = 0; j < 26; j++) {
      if (j >= x[i] - 'a') break;
      if (tmp[j] <= 0) continue;
      ans = (ans + cur * f[L - 1] % mod * Inv[L] % mod * f[tmp[j]] % mod *
                       Inv[tmp[j] - 1] % mod) %
            mod;
    }
    if (tmp[x[i] - 'a'] == 0) break;
    cur = cur * f[L - 1] % mod * Inv[L] % mod * f[tmp[x[i] - 'a']] % mod *
          Inv[tmp[x[i] - 'a'] - 1] % mod;
    L--;
    tmp[x[i] - 'a']--;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  lena = a.size();
  for (int i = 0; i < lena; i++) {
    cnt[a[i] - 'a']++;
  }
  init();
  cout << (solve(b) - solve(a) - 1 + mod) % mod << endl;
  return 0;
}
