#include <bits/stdc++.h>
using namespace std;
string a, b;
const long long MOD = (long long)1e9 + 7;
long long fact[1000006];
long long _fact[1000006];
int cnt[26];
long long bin_pow(long long n, long long k) {
  long long res = 1;
  while (k) {
    if (k & 1) res = (res * n) % MOD;
    n = (n * n) % MOD;
    k >>= 1;
  }
  return res;
}
long long calc(string s) {
  long long res = 0;
  long long perm = fact[a.size()];
  for (int i = 0; i < 26; i++) {
    cnt[i] = 0;
  }
  for (int i = 0; i < a.size(); i++) {
    cnt[a[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    perm = (perm * _fact[cnt[i]]) % MOD;
  }
  for (int i = 0; i < a.size(); i++) {
    perm = (perm * _fact[a.size() - i]) % MOD;
    perm = (perm * fact[a.size() - i - 1]) % MOD;
    for (int j = 0; j < s[i] - 'a'; j++) {
      if (!cnt[j]) continue;
      perm = (perm * fact[cnt[j]]) % MOD;
      cnt[j]--;
      perm = (perm * _fact[cnt[j]]) % MOD;
      res = (res + perm) % MOD;
      perm = (perm * fact[cnt[j]]) % MOD;
      cnt[j]++;
      perm = (perm * _fact[cnt[j]]) % MOD;
    }
    if (!cnt[s[i] - 'a']) break;
    perm = (perm * fact[cnt[s[i] - 'a']]) % MOD;
    cnt[s[i] - 'a']--;
    perm = (perm * _fact[cnt[s[i] - 'a']]) % MOD;
  }
  return res;
}
int main() {
  fact[0] = 1;
  for (int i = 1; i <= 1000000; i++) {
    fact[i] = (fact[i - 1] * i) % MOD;
  }
  _fact[1000000] = bin_pow(fact[1000000], MOD - 2);
  for (int i = 999999; i >= 0; i--) {
    _fact[i] = (_fact[i + 1] * (i + 1)) % MOD;
  }
  cin >> a >> b;
  cout << (calc(b) - calc(a) - 1 + MOD) % MOD << '\n';
  return 0;
}
