#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const long long MOD = 1000000007;
long long fact[N], revFact[N];
char a[N], b[N];
int n;
int quickPow(long long base, long long x) {
  long long ans = 1;
  while (x) {
    if (x & 1) {
      ans *= base;
      ans %= MOD;
    }
    base *= base;
    base %= MOD;
    x >>= 1;
  }
  return ans;
}
void init() {
  fact[0] = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  revFact[n] = quickPow(fact[n], MOD - 2);
  for (int i = n - 1; i >= 0; i--) {
    revFact[i] = revFact[i + 1] * (i + 1) % MOD;
  }
}
long long gao(char *x) {
  int cnt[26];
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < n; i++) cnt[a[i]]++;
  long long divNum = 1LL;
  for (int i = 0; i < 26; i++) {
    divNum = divNum * revFact[cnt[i]] % MOD;
  }
  long long ans = 0LL;
  long long prev = 1LL;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < x[i]; j++) {
      if (cnt[j]) {
        long long tmp = prev * cnt[j] % MOD * fact[n - i - 1] % MOD;
        ans = (ans + tmp) % MOD;
      }
    }
    if (cnt[x[i]]) {
      prev = prev * cnt[x[i]] % MOD;
      cnt[x[i]]--;
    } else {
      break;
    }
  }
  return ans * divNum % MOD;
}
int main() {
  scanf("%s%s", a, b);
  n = strlen(a);
  init();
  for (int i = 0; i < n; i++) {
    a[i] -= 'a';
    b[i] -= 'a';
  }
  printf("%I64d\n", (gao(b) - gao(a) + MOD - 1 + MOD) % MOD);
  return 0;
}
