#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int N = 1e6 + 7;
const long long mod = 1e9 + 7;
char s1[N], s2[N];
int fac[N], invfac[N], cnt[26], buc[26];
inline int qpow(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) r = (long long)r * a % mod;
    a = (long long)a * a % mod;
    b >>= 1;
  }
  return r;
}
long long calc(char s[], char t[], int len) {
  memcpy(cnt, buc, sizeof(buc));
  long long ans = 0;
  long long down = 1LL;
  for (int i = 0; i < 26; ++i) down = (long long)down * invfac[cnt[i]] % mod;
  for (int i = 0; i < len; ++i) {
    for (int j = 0; j < t[i] - 'a'; ++j) {
      if (cnt[j]) {
        --cnt[j];
        long long oth =
            (long long)down * fac[cnt[j] + 1] % mod * invfac[cnt[j]] % mod;
        long long temp = (long long)fac[len - 1 - i] * oth % mod;
        ans = (ans + temp) % mod;
        ++cnt[j];
      }
    }
    if (!cnt[t[i] - 'a']) break;
    --cnt[t[i] - 'a'];
    down = (long long)down * fac[cnt[t[i] - 'a'] + 1] % mod *
           invfac[cnt[t[i] - 'a']] % mod;
  }
  return ans;
}
int main(void) {
  int i;
  fac[0] = 1;
  for (i = 1; i < N; ++i) fac[i] = (long long)fac[i - 1] * i % mod;
  invfac[N - 1] = qpow(fac[N - 1], mod - 2);
  for (i = N - 2; i >= 0; --i)
    invfac[i] = (long long)invfac[i + 1] * (i + 1) % mod;
  while (~scanf("%s%s", s1, s2)) {
    for (i = 0; i < 26; ++i) buc[i] = 0;
    int len = strlen(s1);
    for (i = 0; i < len; ++i) ++buc[s1[i] - 'a'];
    long long A = calc(s1, s2, len);
    long long B = calc(s1, s1, len);
    printf("%I64d\n", (long long)(A - B - 1LL + mod) % mod);
  }
  return 0;
}
