#include <bits/stdc++.h>
const int MOD = 1000000007;
inline int mul(int x, int y) { return (long long)x * (long long)y % MOD; }
inline int add(int x, int y) {
  int r = x + y;
  if (r >= MOD) r -= MOD;
  return r;
}
inline int fpm(int a, int p) {
  int ans = 1;
  for (int x = a; p; p >>= 1) {
    if (p & 1) ans = mul(ans, x);
    x = mul(x, x);
  }
  return ans;
}
using namespace std;
const int MAXN = 1000010;
int fac[MAXN], ifac[MAXN], N, cnt[26];
char A[MAXN], B[MAXN];
inline int work() {
  int i, k, Ans = 0, Tinv = 1, len;
  memset(cnt, 0, sizeof(cnt));
  for (i = 0; i < N; i++) cnt[A[i] - 'a']++;
  for (k = 0; k < 26; k++) Tinv = mul(Tinv, ifac[cnt[k]]);
  for (i = 0; i < N; i++) {
    len = N - i;
    for (k = 0; k < B[i] - 'a'; k++)
      if (cnt[k])
        Ans = add(Ans, mul(fac[len - 1],
                           mul(mul(Tinv, fac[cnt[k]]), ifac[cnt[k] - 1])));
    k = B[i] - 'a';
    if (!cnt[k]) break;
    Tinv = mul(Tinv, mul(fac[cnt[k]], ifac[cnt[k] - 1]));
    cnt[k]--;
  }
  return Ans;
}
int main() {
  int i;
  scanf("%s%s", A, B);
  N = strlen(A);
  fac[0] = ifac[0] = 1;
  fac[1] = 1;
  for (i = 2; i <= N; i++) fac[i] = mul(fac[i - 1], i);
  ifac[N] = fpm(fac[N], MOD - 2);
  for (i = N - 1; i >= 1; i--) ifac[i] = mul(ifac[i + 1], i + 1);
  int V1 = work();
  memcpy(B, A, N);
  printf("%d", add(V1, MOD - work() - 1));
}
