#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
vector<long long> factMod___;
vector<long long> factModInv;
vector<long long> perms;
int sz;
vector<int> cnts(26);
long long powMod(long long n, int p) {
  if (!p) return 1;
  if (p == 1) return n;
  if (p == 2) return n * n % MOD;
  return powMod(powMod(n, p / 2), 2) * (p % 2 ? n : 1) % MOD;
}
long long permutations(vector<int>& cnts, int sz) {
  long long ans = factMod___[sz];
  for (int i : cnts)
    if (i) {
      ans = (ans * factModInv[i]) % MOD;
    }
  return ans;
}
void init(string& s) {
  sz = s.size();
  int len = sz + 1;
  factMod___ = vector<long long>(len, 1);
  for (long long i = 2; i < len; ++i)
    factMod___[i] = factMod___[i - 1] * i % MOD;
  factModInv = vector<long long>(len);
  factModInv[len - 1] = powMod(factMod___[len - 1], MOD - 2);
  for (long long i = len - 1; i > 0; --i)
    factModInv[i - 1] = factModInv[i] * i % MOD;
  for (char c : s) ++cnts[c - 'a'];
}
long long countBelow(string& s) {
  bool found = true;
  auto cntstmp = cnts;
  long long ans = 0;
  long long perm = permutations(cnts, sz);
  for (int i = 0; i < sz && found; ++i) {
    perm = perm * factMod___[sz - 1 - i] % MOD;
    perm = perm * factModInv[sz - i] % MOD;
    found = false;
    for (int j = 0; j < 26; ++j)
      if (cntstmp[j]) {
        if (j < s[i] - 'a') {
          perm = perm * factMod___[cntstmp[j]] % MOD;
          perm = perm * factModInv[cntstmp[j] - 1] % MOD;
          ans += perm;
          ans %= MOD;
          perm = perm * factMod___[cntstmp[j] - 1] % MOD;
          perm = perm * factModInv[cntstmp[j]] % MOD;
        } else if (j == s[i] - 'a') {
          found = true;
          perm = perm * factMod___[cntstmp[j]] % MOD;
          --cntstmp[j];
          perm = perm * factModInv[cntstmp[j]] % MOD;
        } else
          break;
      }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  string a, b;
  cin >> a >> b;
  init(a);
  long long belowA = countBelow(a);
  long long belowB = countBelow(b);
  cout << (belowB - belowA - 1 + MOD) % MOD;
  return 0;
}
