#include <bits/stdc++.h>
using namespace std;
long long int mod = (long long int)1e9 + 7;
long long int cnta[26] = {0};
long long int cnta2[26] = {0};
long long int ans = 0;
long long int fact[1000001] = {0};
long long int inv[1000001] = {0};
long long int exp(long long int x, long long int n, long long int p);
long long int inverse(long long int x) { return exp(x, mod - 2, mod); }
void solve() {
  string c, d;
  cin >> c >> d;
  long long int idx = 0;
  for (long long int i = 0; i < (long long int)c.size(); i++) {
    if (c[i] != d[i]) {
      idx = i;
      break;
    }
  }
  string a = "", b = "";
  for (long long int i = idx; i < (long long int)c.size(); i++) {
    a += c[i];
    cnta[c[i] - 'a']++;
    cnta2[c[i] - 'a']++;
    b += d[i];
  }
  long long int n = (long long int)a.size();
  long long int factor = 1;
  for (long long int j = 0; j < 26; j++) {
    factor *= inv[cnta[j]];
    if (factor >= mod) factor %= mod;
  }
  long long int factor2 = factor;
  for (long long int i = (a[0] - 'a') + 1; i < (b[0] - 'a'); i++) {
    if (cnta[i]) {
      long long int prod = fact[n - 1];
      for (long long int j = 0; j < 26; j++) {
        if (j != i) {
          prod *= inv[cnta[j]];
          if (prod >= mod) prod %= mod;
        } else {
          prod *= inv[cnta[j] - 1];
          if (prod >= mod) prod %= mod;
        }
      }
      ans += prod;
      if (ans >= mod) {
        ans %= mod;
      }
    }
  }
  for (long long int i = 0; i < n - 1; i++) {
    factor *= fact[cnta[a[i] - 'a']];
    cnta[a[i] - 'a']--;
    factor %= mod;
    factor *= inv[cnta[a[i] - 'a']];
    factor %= mod;
    for (long long int j = (a[i + 1] - 'a') + 1; j < 26; j++) {
      if (cnta[j]) {
        long long int prod = fact[n - (i + 2)];
        long long int f = factor;
        f *= inv[cnta[j] - 1];
        if (f >= mod) f %= mod;
        f *= fact[cnta[j]];
        if (f >= mod) f %= mod;
        prod *= f;
        if (prod >= mod) prod %= mod;
        ans += prod;
        if (ans >= mod) {
          ans %= mod;
        }
      }
    }
  }
  for (long long int i = 0; i < n - 1; i++) {
    if (!cnta2[b[i] - 'a']) {
      break;
    }
    factor2 *= fact[cnta2[b[i] - 'a']];
    if (factor2 >= mod) factor2 %= mod;
    cnta2[b[i] - 'a']--;
    factor2 *= inv[cnta2[b[i] - 'a']];
    if (factor2 >= mod) factor2 %= mod;
    for (long long int j = 0; j < (b[i + 1] - 'a'); j++) {
      if (cnta2[j]) {
        long long int prod = fact[n - (i + 2)];
        long long int f = factor2;
        f *= inv[cnta2[j] - 1];
        if (f >= mod) f %= mod;
        f *= fact[cnta2[j]];
        if (f >= mod) f %= mod;
        prod *= f;
        if (prod >= mod) prod %= mod;
        ans += prod;
        if (ans >= mod) {
          ans %= mod;
        }
      }
    }
  }
  cout << ans << "\n";
  return;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  t = 1;
  fact[0] = 1;
  inv[0] = inverse(fact[0]);
  for (long long int j = 1; j <= 1e6; j++) {
    fact[j] = fact[j - 1] * j;
    if (fact[j] >= mod) fact[j] %= mod;
    inv[j] = inverse(fact[j]);
  }
  while (t--) {
    solve();
  }
  return 0;
}
long long int exp(long long int x, long long int n, long long int p) {
  if (n == 0) {
    return 1;
  } else if (n == 1) {
    return x % p;
  } else {
    if (n % 2 == 0) {
      return (exp((x * x) % p, n / 2, p));
    } else {
      return (x * exp((x * x) % p, n / 2, p)) % p;
    }
  }
}
