#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
  return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
  return n & ~((T)1 << pos);
}
template <class T>
inline T ison(T n, T pos) {
  return (bool)(n & ((T)1 << pos));
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <typename T>
string NumberToString(T Number) {
  ostringstream second;
  second << Number;
  return second.str();
}
inline int nxt() {
  int aaa;
  scanf("%d", &aaa);
  return aaa;
}
inline long long int lxt() {
  long long int aaa;
  scanf("%lld", &aaa);
  return aaa;
}
inline double dxt() {
  double aaa;
  scanf("%lf", &aaa);
  return aaa;
}
template <class T>
inline T bigmod(T p, T e, T m) {
  T ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % m;
    p = (p * p) % m;
  }
  return (T)ret;
}
long long int fac[2000010], finv[2000010];
pair<long long int, long long int> extendedEuclid(long long int a,
                                                  long long int b) {
  if (b == 0)
    return pair<long long int, long long int>(1, 0);
  else {
    pair<long long int, long long int> d = extendedEuclid(b, a % b);
    return pair<long long int, long long int>(d.second,
                                              d.first - d.second * (a / b));
  }
}
long long int modularInverse(long long int a, long long int n) {
  pair<long long int, long long int> ret = extendedEuclid(a, n);
  return ((ret.first % n) + n) % n;
}
void gen() {
  fac[0] = 1;
  for (long long int i = 1; i < 2000010; i++)
    fac[i] = (i * fac[i - 1]) % 1000000007;
  finv[2000010 - 1] =
      modularInverse(fac[2000010 - 1], (long long int)1000000007);
  for (long long int i = 2000010 - 2; i >= 0; i--)
    finv[i] = (finv[i + 1] * (i + 1)) % 1000000007;
}
long long int ncr(int n, int k) {
  return (((fac[n] * finv[k]) % 1000000007) * finv[n - k]) % 1000000007;
}
long long int go(int cnt[], string s) {
  long long int ans = 0;
  for (int i = 0; i < s.length(); i++) {
    long long int tmp = fac[s.length() - i - 1];
    for (int j = 0; j <= 25; j++) {
      if (cnt[j]) {
        tmp *= finv[cnt[j]];
        tmp %= 1000000007;
      }
    }
    for (int j = 0; j < s[i] - 'a'; j++) {
      if (cnt[j]) {
        tmp *= fac[cnt[j]];
        tmp %= 1000000007;
        tmp *= finv[cnt[j] - 1];
        tmp %= 1000000007;
        ans += tmp;
        ans %= 1000000007;
        tmp *= fac[cnt[j] - 1];
        tmp %= 1000000007;
        tmp *= finv[cnt[j]];
        tmp %= 1000000007;
      }
    }
    if (cnt[s[i] - 'a'])
      cnt[s[i] - 'a']--;
    else
      break;
  }
  return ans;
}
int main() {
  gen();
  string a, b;
  cin >> a >> b;
  int cnt[26] = {0};
  for (int i = 0; i < a.size(); i++) cnt[a[i] - 'a']++;
  long long int ans = go(cnt, b);
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < a.size(); i++) cnt[a[i] - 'a']++;
  ans -= go(cnt, a) + 1;
  ans += 1000000007;
  ans %= 1000000007;
  cout << ans << endl;
  return 0;
}
