#include <bits/stdc++.h>
using namespace std;
int n;
int ans[2];
int cnt[26];
int cnt2[26];
long long fact[1000003];
string s1, s2, t;
long long calcPow(long long x, long long y) {
  if (!y) return 1;
  long long tmp = calcPow(x, y / 2);
  tmp = (tmp * tmp) % 1000000007;
  if (y & 1) tmp = (tmp * x) % 1000000007;
  return tmp;
}
void f(int ind, int kd, long long q) {
  if (ind == n) {
    ans[kd] = (ans[kd] + 1) % 1000000007;
    return;
  }
  int val = t[ind] - 'a';
  for (int i = 0; i < val; i++)
    if (cnt[i]) {
      long long add = (q * cnt[i]) % 1000000007;
      add = (add * fact[n - ind - 1]) % 1000000007;
      ans[kd] = (ans[kd] + add) % 1000000007;
    }
  if (cnt[val]) {
    long long c = cnt[val];
    cnt[val]--;
    f(ind + 1, kd, (q * c) % 1000000007);
    cnt[val]++;
  }
}
int main() {
  cin >> s1 >> s2;
  n = s1.length();
  for (int i = 0; i < n; i++) cnt[s1[i] - 'a']++;
  for (int i = 0; i < n; i++) cnt2[s2[i] - 'a']++;
  bool same = true;
  for (int i = 0; i < 26; i++)
    if (cnt[i] != cnt2[i]) same = false;
  fact[0] = 1;
  for (int i = 1; i <= n; i++) fact[i] = (fact[i - 1] * i) % 1000000007;
  long long q = 1;
  for (int i = 0; i < 26; i++) q = (q * fact[cnt[i]]) % 1000000007;
  q = calcPow(q, 1000000007 - 2);
  t = s1;
  f(0, 0, q);
  t = s2;
  f(0, 1, q);
  int res = (ans[1] - ans[0] + 1000000007) % 1000000007;
  res = (res - same + 1000000007) % 1000000007;
  printf("%d\n", res);
}
