#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
const long long M = 1e9 + 7;
long long mod(long long m, long long mod = M) {
  m %= mod;
  return (m + mod) % mod;
}
long long power(long long x, long long y) {
  long long res = 1;
  x = mod(x);
  while (y > 0) {
    if (y & 1) res = mod(res * x);
    y = y / 2;
    x = mod(x * x);
  }
  return mod(res);
}
long long f[N], invf[N];
void fact() {
  f[0] = f[1] = 1;
  for (long long i = 2; i < N; i++) f[i] = mod(f[i - 1] * i);
  invf[N - 1] = power(f[N - 1], M - 2);
  for (long long i = N - 1; i > 0; i--) invf[i - 1] = mod(invf[i] * i);
}
vector<long long> fr;
long long solve(string s) {
  long long n = s.size();
  vector<long long> curf = fr;
  long long ans = 0, cur = f[n];
  for (long long i = 0; i < 26; i++) cur = mod(cur * invf[curf[i]]);
  for (long long i = 0; i < s.size(); i++) {
    cur = mod(cur * power(n - i, M - 2));
    for (char c = 'a'; c < s[i]; c++) {
      if (curf[c - 'a'] == 0) continue;
      ans = mod(ans + mod(cur * curf[c - 'a']));
    }
    if (curf[s[i] - 'a'] == 0) break;
    cur = mod(cur * curf[s[i] - 'a']);
    curf[s[i] - 'a']--;
  }
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  fact();
  string a, b;
  cin >> a >> b;
  fr.resize(26, 0);
  for (char c : a) fr[c - 'a']++;
  long long ans = solve(b) - solve(a) - 1;
  ans = mod(ans);
  cout << ans << '\n';
}
