#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
const long long Pt = 1e9 + 7;
char A[MAXN + 5], B[MAXN + 5];
long long f[MAXN + 5], Nval[MAXN + 5];
int num[500];
int N;
long long qum(long long x, long long N) {
  if (N == 0) return 1;
  long long c = qum(x, N / 2);
  if (N & 1) return c * c % Pt * x % Pt;
  return c * c % Pt;
}
long long dfs_1(int now, long long ret) {
  long long sumv = 0;
  if (now == N)
    return 1;
  else {
    for (int i = 'a'; i <= 'z'; i++) {
      if (i < A[now] && num[i])
        sumv = (sumv + ret * Nval[N - now + 1] % Pt * f[N - now] % Pt *
                           f[num[i]] % Pt * Nval[num[i] - 1] % Pt) %
               Pt;
      else if (i == A[now] && num[i]) {
        ret = ret * Nval[N - now + 1] % Pt * f[N - now] % Pt * f[num[i]] % Pt *
              Nval[num[i] - 1] % Pt;
        num[i]--;
        sumv = (sumv + dfs_1(now + 1, ret)) % Pt;
        num[i]++;
      }
    }
  }
  return sumv;
}
long long dfs_2(int now, long long ret) {
  long long sumv = 0;
  if (now == N) {
    if (A[now] >= B[now]) return 0;
    return 1;
  } else {
    for (int i = 'a'; i <= 'z'; i++) {
      if (i < B[now] && num[i])
        sumv = (sumv + ret * Nval[N - now + 1] % Pt * f[N - now] % Pt *
                           f[num[i]] % Pt * Nval[num[i] - 1] % Pt) %
               Pt;
      else if (i == B[now] && num[i]) {
        ret = ret * Nval[N - now + 1] % Pt * f[N - now] % Pt * f[num[i]] % Pt *
              Nval[num[i] - 1] % Pt;
        num[i]--;
        sumv = (sumv + dfs_2(now + 1, ret)) % Pt;
        num[i]++;
      }
    }
  }
  return sumv;
}
int main() {
  long long ans = 1;
  f[0] = 1;
  for (long long i = 1; i <= MAXN; i++) ans = ans * i % Pt, f[i] = ans;
  for (int i = 0; i <= MAXN; i++) Nval[i] = qum(f[i], Pt - 2);
  scanf("%s%s", A + 1, B + 1);
  N = strlen(A + 1);
  for (int i = 1; i <= N; i++) num[A[i]]++;
  long long sum = f[N];
  for (int i = 'a'; i <= 'z'; i++) sum = sum * Nval[num[i]] % Pt;
  long long suma = dfs_1(1, sum);
  long long sumb = dfs_2(1, sum);
  printf("%I64d\n", (sumb - suma + Pt) % Pt);
}
