#include <bits/stdc++.h>
using namespace std;
string a, b;
long long int pres[30], fac[1100000], modinv[1100000];
long long int pow1(long long int a, long long int b) {
  if (b == 0)
    return 1ll;
  else if (b == 1)
    return a;
  else {
    long long int x = pow1(a, b / 2);
    x *= x;
    x %= 1000000007;
    if (b % 2) {
      x *= a;
      x %= 1000000007;
    }
    return x;
  }
}
void init() {
  fac[0] = 1;
  modinv[0] = 1;
  fac[1] = 1;
  modinv[1] = 1;
  for (long long int i = 2; i <= 1000000; i++) {
    fac[i] = (fac[i - 1] * i) % 1000000007;
    modinv[i] = pow1(fac[i], 1000000007 - 2);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  init();
  cin >> a >> b;
  int l = 0;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == b[i])
      l++;
    else
      break;
  }
  long long int ans = 0;
  pres[a[a.size() - 1] - 'a']++;
  for (int i = b.size() - 2; i >= l; i--) {
    pres[a[i] - 'a']++;
    long long int temp = 1;
    for (int j = 0; j < 26; j++) {
      if (pres[j] > 0) {
        temp *= modinv[pres[j]];
        temp %= 1000000007;
      }
    }
    for (int x = a[i] + 1; x <= 'z'; x++) {
      if (i == l and x >= b[i]) break;
      if (pres[x - 'a']) {
        ans += (((temp * pres[x - 'a']) % 1000000007) * fac[b.size() - i - 1]) %
               1000000007;
        ans %= 1000000007;
      }
    }
  }
  for (int i = l; i <= b.size() - 2; i++) {
    if (pres[b[i] - 'a']) {
      pres[b[i] - 'a']--;
      long long int temp = 1;
      for (int j = 0; j < 26; j++) {
        if (pres[j] > 0) {
          temp *= modinv[pres[j]];
          temp %= 1000000007;
        }
      }
      for (int x = 0; x < b[i + 1] - 'a'; x++) {
        if (pres[x]) {
          ans += (((temp * pres[x]) % 1000000007) * fac[b.size() - i - 2]) %
                 1000000007;
          ans %= 1000000007;
        }
      }
    } else
      break;
  }
  cout << ans << "\n";
  return 0;
}
