#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
const int mod = 1e9 + 7;
char s[N], t[N];
long long f[N], invf[N], nnf[N];
int num[30];
int num2[30];
int n;
long long qpow(int x, int b) {
  long long sum = 1;
  long long now = x;
  while (b) {
    if (b & 1) sum = sum * now % mod;
    now = now * now % mod;
    b >>= 1;
  }
  return sum;
}
void init() {
  f[0] = 1;
  for (int i = 1; i < N; i++) {
    f[i] = f[i - 1] * i % mod;
  }
  for (int i = 0; i < N; i++) {
    invf[i] = qpow(f[i], mod - 2);
  }
  for (int i = 0; i < N; i++) {
    nnf[i] = qpow(invf[i], mod - 2);
  }
}
void add(int &x, int y) {
  x += y;
  if (x > mod) x -= mod;
}
int solve(char *st, int len) {
  int ret = 0;
  for (int i = 0; i < len; i++) {
    int now = st[i] - 'a';
    long long cns = 1;
    for (int j = 0; j < 26; j++) cns = cns * invf[num[j]] % mod;
    for (int j = now + 1; j < 26; j++) {
      if (num[j] == 0) continue;
      int res = len - i - 1;
      int tmp = f[res] * cns % mod;
      tmp = tmp * nnf[num[j]] % mod;
      tmp = tmp * invf[num[j] - 1] % mod;
      add(ret, tmp);
    }
    if (num[now] == 0) return ret;
    num[now]--;
  }
  return ret;
}
int main() {
  init();
  scanf("%s %s", s, t);
  n = strlen(s);
  for (int i = 0; i < n; i++) {
    num[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) num2[i] = num[i];
  int ans1 = solve(s, n);
  for (int i = 0; i < 26; i++) num[i] = num2[i];
  int ans2 = solve(t, n);
  bool tmp = true;
  for (int i = 0; i < n; i++) num2[t[i] - 'a']--;
  for (int i = 0; i < 26; i++)
    if (num2[i] != 0) tmp = false;
  if (tmp) ans2++;
  cout << (ans1 - ans2 + mod) % mod << endl;
  return 0;
}
