#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000001;
int s[MAXN];
long long int pot[MAXN];
long long int inv[MAXN];
int cont[MAXN];
long long int power(long long int a, int b) {
  long long int ans = 1ll;
  while (b) {
    if (b & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
long long int solve(int n, int ini, int fin) {
  long long int uno = pot[n - 1], dos = 1ll, ans = 0ll;
  for (int j = 0; j < 26; j++) dos = (dos * inv[cont[j + 'a']]) % 1000000007;
  for (int j = ini; j <= fin; j++)
    if (cont[j]) {
      long long int aux = (dos * pot[cont[j]]) % 1000000007;
      aux = (aux * inv[cont[j] - 1]) % 1000000007;
      aux = (uno * aux) % 1000000007;
      ans += aux;
      ans %= 1000000007;
    }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  pot[0] = 1ll;
  for (int i = 0; i < MAXN; i++)
    if (i) pot[i] = (pot[i - 1] * (long long int)i) % 1000000007;
  for (int i = 0; i < MAXN; i++) inv[i] = power(pot[i], 1000000007 - 2);
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < a.size(); i++) cont[a[i]]++;
  int n = a.size(), f = 1;
  long long int ans = 0ll;
  for (int i = 0; i < a.size(); i++) {
    int ini = a[i] + 1, fin = (f ? b[i] - 1 : 'z');
    if (b[i] > a[i]) f = 0;
    ans = (ans + solve(n, ini, fin)) % 1000000007;
    n--;
    cont[a[i]]--;
  }
  for (int i = 0; i < a.size(); i++) cont[a[i]]++;
  n = a.size();
  f = 1;
  for (int i = 0; i < b.size(); i++) {
    if (!cont[b[i]]) break;
    cont[b[i]]--;
    if (b[i] > a[i]) f = 0;
    if (f || i == a.size() - 1) continue;
    n--;
    int fin = b[i + 1] - 1, ini = 'a';
    ans = (ans + solve(n, ini, fin)) % 1000000007;
  }
  cout << ans << '\n';
  return 0;
}
