#include <bits/stdc++.h>
using namespace std;
long long *freqs;
long long mod = 1000000007;
long long fact[1000001];
long long inv_fact[1000001];
long long expo(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b % 2) res = (res * a) % mod;
    a = (a * a) % mod;
    b /= 2;
  }
  return res;
}
long long func(string s) {
  long long ans = 0;
  int n = s.length();
  for (int i = 0; i < n; i++) {
    long long denom = 1;
    for (int i = 0; i < 26; i++) denom = (denom * inv_fact[freqs[i]]) % mod;
    for (int j = 0; j < (s[i] - 'a'); j++) {
      if (freqs[j]) {
        long long temp =
            (((fact[n - i - 1] * fact[freqs[j]]) % mod) * denom) % mod;
        temp = (temp * inv_fact[freqs[j] - 1]) % mod;
        ans += temp;
        ans %= mod;
      }
    }
    if (freqs[s[i] - 'a'] == 0) {
      break;
    }
    freqs[s[i] - 'a']--;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  fact[0] = inv_fact[0] = 1;
  for (long long i = 1; i <= 1000000; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
    inv_fact[i] = expo(fact[i], mod - 2);
  }
  string s1, s2;
  cin >> s1 >> s2;
  freqs = new long long[26];
  for (int i = 0; i < 26; i++) freqs[i] = 0;
  for (int i = 0; i < s1.length(); i++) {
    freqs[s1[i] - 'a']++;
  }
  long long ans1 = func(s2);
  for (int i = 0; i < 26; i++) freqs[i] = 0;
  for (int i = 0; i < s1.length(); i++) {
    freqs[s1[i] - 'a']++;
  }
  long long ans2 = func(s1);
  cout << (ans1 - ans2 - 1 + mod + mod) % mod;
}
