#include <bits/stdc++.h>
using namespace std;
template <typename T>
void printvec(vector<T>& vec) {
  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i] << " ";
  }
  cout << "\n";
}
vector<long long> fact(1000 * 1000 + 1), ifact(1000 * 1000 + 1);
long long power(long long a, long long b) {
  if (b == 0) return 1;
  long long temp = power(a, b / 2);
  temp = (temp * temp) % (1000 * 1000 * 1000 + 7);
  if (b % 2 == 1) {
    return (temp * a) % (1000 * 1000 * 1000 + 7);
  } else {
    return temp;
  }
}
void preprocess() {
  fact[0] = 1;
  long long i;
  for (i = 1; i < fact.size(); i++) {
    fact[i] = (fact[i - 1] * i) % (1000 * 1000 * 1000 + 7);
  }
  ifact[0] = 1;
  for (i = 1; i < ifact.size(); i++) {
    ifact[i] = power(i, (1000 * 1000 * 1000 + 7) - 2);
    ifact[i] = (ifact[i - 1] * ifact[i]) % (1000 * 1000 * 1000 + 7);
  }
}
string str1, str2;
vector<long long> freq(26, 0);
long long solve(string str) {
  long long ans = 0, i, j, k, n = str.length();
  vector<long long> cnt(freq);
  for (i = 0; i < str1.length(); i++) {
    long long temp = 1;
    temp = (temp * fact[n - 1]) % (1000 * 1000 * 1000 + 7);
    for (j = 0; j < 26; j++) {
      temp = (temp * ifact[cnt[j]]) % (1000 * 1000 * 1000 + 7);
    }
    long long temp2 = 0;
    for (j = 0; str[i] - 'a' > j; j++) {
      if (cnt[j] == 0) continue;
      long long a =
          (fact[cnt[j]] * ifact[cnt[j] - 1]) % (1000 * 1000 * 1000 + 7);
      temp2 = (temp2 + a) % (1000 * 1000 * 1000 + 7);
    }
    temp = (temp * temp2) % (1000 * 1000 * 1000 + 7);
    n--;
    ans = (ans + temp) % (1000 * 1000 * 1000 + 7);
    if (cnt[j] != 0) {
      cnt[j]--;
    } else {
      break;
    }
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  int ttt = 1;
  while (ttt--) {
    cin >> str1 >> str2;
    int i;
    for (i = 0; i < str1.length(); i++) {
      freq[str1[i] - 'a']++;
    }
    preprocess();
    cout << (solve(str2) - solve(str1) + (1000 * 1000 * 1000 + 7) - 1) %
                (1000 * 1000 * 1000 + 7)
         << "\n";
  }
  return 0;
}
