#include <bits/stdc++.h>
using namespace std;
const long long INF = 4e18;
const int N = 1100000;
const int M = 70;
const int MOD = 1e9 + 7;
const int nbits = 20;
void add(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
int sum(int a, int b) { return (a + b) % MOD; }
void mult(int &a, int b) { a = (1ll * a * b) % MOD; }
int product(int a, int b) { return (1ll * a * b) % MOD; }
int fact[N], fact1[N];
int cnt[N];
string a, b;
int power(int b, int p) {
  int res = 1;
  while (p) {
    if (p & 1) {
      mult(res, b);
    }
    mult(b, b);
    p /= 2;
  }
  return res;
}
void precalc() {
  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = product(fact[i - 1], i);
  for (int i = 0; i < N; i++) fact1[i] = power(fact[i], MOD - 2);
}
void truncate(string &s, string &t) {
  int n = s.length();
  int len = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == t[i])
      len++;
    else
      break;
  }
  string s1 = "";
  for (int i = len; i < n; i++) s1 += s[i];
  string t1 = "";
  for (int i = len; i < n; i++) t1 += t[i];
  s = s1;
  t = t1;
}
int solve(const string &s, const string &t) {
  int n = a.length();
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < n; i++) {
    cnt[s[i] - 'a']++;
  }
  int ans = 0;
  int pr = 1;
  for (int i = 0; i < 26; i++) mult(pr, fact1[cnt[i]]);
  for (int i = 0; i < n; i++) {
    int c1 = s[i] - 'a', c2 = t[i] - 'a';
    if (i == 0)
      c2--;
    else
      c2 = 26;
    for (int c = c1 + 1; c <= c2; c++) {
      if (cnt[c] == 0) continue;
      int pr1 = pr;
      mult(pr, fact[cnt[c]]);
      cnt[c]--;
      mult(pr, fact1[cnt[c]]);
      add(ans, product(pr, fact[n - i - 1]));
      cnt[c]++;
      pr = pr1;
    }
    mult(pr, fact[cnt[c1]]);
    cnt[c1]--;
    mult(pr, fact1[cnt[c1]]);
  }
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < n; i++) {
    cnt[s[i] - 'a']++;
  }
  pr = 1;
  for (int i = 0; i < 26; i++) mult(pr, fact1[cnt[i]]);
  for (int i = 0; i < n; i++) {
    int c1 = 0, c2 = t[i] - 'a';
    if (i != 0) {
      for (int c = c1; c < c2; c++) {
        if (cnt[c] == 0) continue;
        int pr1 = pr;
        mult(pr, fact[cnt[c]]);
        cnt[c]--;
        mult(pr, fact1[cnt[c]]);
        add(ans, product(pr, fact[n - i - 1]));
        cnt[c]++;
        pr = pr1;
      }
    }
    if (cnt[c2] == 0) break;
    mult(pr, fact[cnt[c2]]);
    cnt[c2]--;
    mult(pr, fact1[cnt[c2]]);
  }
  return ans;
}
int main() {
  precalc();
  cin >> a;
  cin >> b;
  truncate(a, b);
  int res = solve(a, b);
  cout << res;
  return 0;
}
