#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void amax(X& x, const Y& y) {
  if (x < y) x = y;
}
template <class X, class Y>
void amin(X& x, const Y& y) {
  if (x > y) x = y;
}
const int INF = 1e9 + 10;
const long long INFL = 1e18 + 10;
const int BASE = 1e9 + 7;
const int MAX = 1e6 + 10;
int n;
string a, b;
int cnt[30];
int fact[MAX], revFact[MAX];
int power(int x, int n) {
  if (n == 0) return 1;
  long long tmp = power(x, n / 2);
  tmp = (tmp * tmp) % BASE;
  if (n & 1) tmp = (tmp * x) % BASE;
  return tmp;
}
int calc(const string& a, const string& b) {
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < n; i++) cnt[a[i] - 'a']++;
  long long res = 0;
  for (int i = 0; i < n; i++) {
    long long t = fact[n - (i + 1)];
    for (int j = 0; j < 26; j++) t = (t * revFact[cnt[j]]) % BASE;
    for (int c = 'a'; c < b[i]; c++)
      if (cnt[c - 'a'] > 0) {
        res = (res + t * cnt[c - 'a']) % BASE;
      }
    if (cnt[b[i] - 'a'] > 0)
      cnt[b[i] - 'a']--;
    else
      break;
  }
  return res;
}
void process() {
  cin >> a >> b;
  n = a.size();
  fact[0] = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = ((long long)fact[i - 1] * i) % BASE;
  }
  for (int i = 0; i <= n; i++) revFact[i] = power(fact[i], BASE - 2);
  int res = (calc(a, b) - calc(a, a) - 1) % BASE;
  if (res < 0) res += BASE;
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  process();
}
