#include <bits/stdc++.h>
using namespace std;
const long double DINF = 1e45;
const long long INF = 1e17;
const long long MOD = 1e9 + 7;
const int MAXF = 1000010;
long long fact[MAXF], inv[MAXF];
long long power(long long base, long long expo, long long MOD) {
  long long res = 1;
  while (expo > 0) {
    if (expo & 1) res = (res * base) % MOD;
    base = (base * base) % MOD;
    expo >>= 1;
  }
  return res;
}
void pre() {
  fact[0] = fact[1] = inv[0] = inv[1] = 1;
  for (int i = 2; i < MAXF; ++i) {
    fact[i] = (fact[i - 1] * i) % MOD;
    inv[i] = power(fact[i], MOD - 2, MOD);
  }
}
long long nck(int n, int k) {
  if (n < k) return 0;
  long long ans = fact[n];
  ans = (ans * inv[k]) % MOD;
  ans = (ans * inv[n - k]) % MOD;
  return ans;
}
long long findfact(int len, int cnt[]) {
  long long ans = fact[len];
  for (int i = 0; i < 26; ++i) {
    ans = (ans * inv[cnt[i]]) % MOD;
  }
  return ans;
}
long long getRank(string a, string b) {
  int n = a.length();
  int m = b.length();
  int cnta[26] = {0};
  int cntb[26] = {0};
  for (auto c : a) {
    cnta[c - 'a']++;
  }
  for (auto c : b) {
    cntb[c - 'b']++;
  }
  long long ans = 0;
  for (int j = 0; j < min(n, m); ++j) {
    int c = b[j] - 'a';
    long long cal = findfact(n - j - 1, cnta);
    for (int i = 0; i < c; ++i) {
      if (cnta[i]) {
        long long temp = (cal * fact[cnta[i]]) % MOD;
        temp = (temp * inv[cnta[i] - 1]) % MOD;
        ans += temp;
      }
    }
    if (!cnta[c]) return ans;
    cnta[b[j] - 'a'] = max(0, cnta[b[j] - 'a'] - 1);
  }
  return ans;
}
int main() {
  pre();
  string a, b;
  cin >> a >> b;
  long long rank1 = getRank(a, a);
  long long rank2 = getRank(a, b);
  long long ans = (rank2 - rank1) % MOD;
  if (ans < 0) ans += MOD;
  ans = (ans - 1) % MOD;
  if (ans < 0) ans += MOD;
  printf("%lld\n", ans);
  return 0;
}
