#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
const long long MOD = 1e9 + 7;
char a[MAXN], c[MAXN];
long long fac[MAXN], ifac[MAXN], inv[MAXN];
int cnt[30] = {0}, n;
int main() {
  scanf("%s", a);
  scanf("%s", c);
  n = strlen(a);
  inv[1] = 1;
  fac[0] = fac[1] = ifac[0] = ifac[1] = 1;
  for (long long i = 2; i <= n; i++) {
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    fac[i] = fac[i - 1] * (1LL * i) % MOD;
    ifac[i] = ifac[i - 1] * inv[i] % MOD;
  }
  n = strlen(a);
  long long subtra = 0, ans = fac[n];
  for (int i = 0; i < n; i++) cnt[a[i] - 'a']++;
  for (int i = 0; i < 26; i++) ans = ans * ifac[cnt[i]] % MOD;
  for (int i = 0; i < n; i++) {
    long long base = fac[n - i - 1];
    for (int j = 0; j < 26; j++) base = (base * ifac[cnt[j]]) % MOD;
    for (int j = 0; j + 'a' < a[i]; j++)
      if (cnt[j]) {
        long long cur = base * fac[cnt[j]] % MOD * ifac[cnt[j] - 1] % MOD;
        subtra = (subtra + cur) % MOD;
      }
    cnt[a[i] - 'a']--;
    if (i == n - 1) subtra = (subtra + 1) % MOD;
  }
  for (int i = 0; i < n; i++) cnt[a[i] - 'a']++;
  for (int i = 0; i < n; i++) {
    long long base = fac[n - i - 1];
    for (int j = 0; j < 26; j++) base = (base * ifac[cnt[j]]) % MOD;
    for (int j = 25; j + 'a' > c[i]; j--)
      if (cnt[j]) {
        long long cur = base * fac[cnt[j]] % MOD * ifac[cnt[j] - 1] % MOD;
        subtra = (subtra + cur) % MOD;
      }
    if (cnt[c[i] - 'a'] == 0) break;
    cnt[c[i] - 'a']--;
    if (i == n - 1) subtra = (subtra + 1) % MOD;
  }
  ans -= subtra;
  if (ans < 0) ans += MOD;
  printf("%I64d\n", ans);
  return 0;
}
