#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, M = 26, Mod = 1e9 + 7;
char a[N], b[N];
long long cnt[M], t[M], rinv[N], inv[N], fac[N];
int n;
long long calc(char s[]) {
  int i, j;
  long long ret = fac[n], ans = 0ll;
  for (i = 0; i < M; i++) t[i] = cnt[i];
  for (i = 0; i < M; i++)
    if (t[i]) ret = (ret * inv[t[i]]) % Mod;
  for (i = 0; i < n; i++) {
    for (j = 0; j < s[i] - 'a'; j++)
      if (t[j]) {
        long long temp = ret;
        temp = temp * rinv[n - i] % Mod;
        temp = temp * t[j] % Mod;
        ans = (ans + temp) % Mod;
      }
    if (t[s[i] - 'a']) {
      ret = ret * rinv[n - i] % Mod;
      ret = ret * t[s[i] - 'a'] % Mod;
      t[s[i] - 'a']--;
    } else
      break;
  }
  return ans;
}
long long power(long long x) {
  long long ans = 1;
  for (long long y = Mod - 2ll; y; y >>= 1ll, x = (x * x) % Mod) {
    if (y & 1) ans = (ans * x) % Mod;
  }
  return ans;
}
int main() {
  long long i;
  scanf("%s%s", a, b);
  n = strlen(a);
  fac[0] = inv[0] = 1;
  for (i = 0; i < n; i++) cnt[a[i] - 'a']++;
  for (i = 1; i < N; i++) {
    rinv[i] = power(i);
    inv[i] = rinv[i] * inv[i - 1] % Mod;
    fac[i] = fac[i - 1] * i % Mod;
  }
  printf("%I64d\n", ((calc(b) + Mod - calc(a)) % Mod + Mod - 1) % Mod);
  return 0;
}
