#include <bits/stdc++.h>
using namespace std;
long long fac[1000005], ifac[1000005];
int c[50], c1[50], l;
long long power(long long ai, long long b, long long c) {
  long long x = 1, y = ai;
  while (b > 0) {
    if (b & 1) x = (x * y) % c;
    y = (y * y) % c;
    b /= 2;
  }
  return x % c;
}
long long cal(int x, int idx) {
  long long ans1 = 0, ans2 = fac[x];
  int l = 26;
  while (idx < l && !c[idx]) idx++;
  if (idx == l) return 0;
  for (int i = 0; i < 26; i++) ans2 = (ans2 * ifac[c[i]]) % 1000000007;
  while (idx < l) {
    if (c[idx]) ans1 = (ans1 + ((ans2 * c[idx]) % 1000000007)) % 1000000007;
    idx++;
  }
  return ans1;
}
int main() {
  long long ans, ans1 = 0, ans2 = 0, x;
  string a, b;
  fac[0] = ifac[0] = fac[1] = ifac[1] = 1;
  for (int i = 2; i <= 1000000; i++) {
    fac[i] = (fac[i - 1] * i) % 1000000007;
    ifac[i] = (ifac[i - 1] * power(i, 1000000007 - 2, 1000000007)) % 1000000007;
  }
  cin >> a >> b;
  l = a.length();
  for (int i = 0; i < l; i++) {
    c[a[i] - 'a']++;
    c1[a[i] - 'a']++;
  }
  for (int i = 0; i < l - 1; i++) {
    ans1 = (ans1 + cal(l - i - 1, a[i] + 1 - 'a')) % 1000000007;
    if (!c[a[i] - 'a']) break;
    c[a[i] - 'a']--;
  }
  for (int i = 0; i < 26; i++) c[i] = c1[i];
  for (int i = 0; i < l - 1; i++) {
    ans2 = (ans2 + cal(l - i - 1, b[i] + 1 - 'a')) % 1000000007;
    if (!c[b[i] - 'a']) break;
    c[b[i] - 'a']--;
  }
  bool flag = true;
  for (int i = 0; i < 26; i++) c[i] = 0;
  for (int i = 0; i < l; i++) c[b[i] - 'a']++;
  for (int i = 0; i < 26; i++) {
    if (c[i] != c1[i]) {
      flag = false;
      break;
    }
  }
  if (flag) ans1 = (ans1 - 1 + 1000000007) % 1000000007;
  ans = (ans1 - ans2 + 1000000007) % 1000000007;
  cout << ans;
  return 0;
}
