#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int BASE = 1e9 + 7;
int n;
int C[26];
char a[N], b[N];
long long fact[N], inv[N];
long long P = 1;
long long Power(long long a, long long p) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = ans * a % BASE;
    a = a * a % BASE;
    p >>= 1;
  }
  return ans;
}
void Mod(long long &a, long long b) { a = (a + b) % BASE; }
void Update(int i, int v) {
  P = P * fact[C[i]] % BASE;
  C[i] += v;
  P = P * inv[C[i]] % BASE;
}
void Init() {
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i % BASE;
  inv[n] = Power(fact[n], BASE - 2);
  for (int i = n - 1; i >= 0; --i) inv[i] = inv[i + 1] * (i + 1) % BASE;
}
long long Count() {
  for (int i = 1; i <= n; ++i) Update(a[i] - 'a', +1);
  long long ans = 0;
  bool Less = a[1] < b[1];
  if (C[b[1] - 'a'] == 0) return ans;
  Update(b[1] - 'a', -1);
  for (int i = 2; i <= n; ++i) {
    for (int j = (Less == false ? a[i] - 'a' + 1 : 'a' - 'a');
         j <= b[i] - 'a' - 1; ++j)
      if (C[j] != 0) {
        Update(j, -1);
        Mod(ans, fact[n - i] * P % BASE);
        Update(j, +1);
      }
    if (C[b[i] - 'a'] == 0) return ans;
    Update(b[i] - 'a', -1);
    Less |= (a[i] < b[i]);
  }
  return ans;
}
int main() {
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  n = strlen(b + 1);
  Init();
  for (int i = 1; i <= n; ++i) {
    Update(a[i] - 'a', +1);
  }
  bool Less = false;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = a[i] - 'a' + 1;
         j <= (Less == false ? b[i] - 'a' - 1 : 'z' - 'a'); ++j)
      if (C[j] != 0) {
        Update(j, -1);
        Mod(ans, fact[n - i] * P % BASE);
        Update(j, +1);
      }
    Less |= (a[i] < b[i]);
    Update(a[i] - 'a', -1);
  }
  Mod(ans, Count());
  printf("%d", ans);
  return 0;
}
