#include <bits/stdc++.h>
using namespace std;
const int MIN = 2e3 + 2;
const int MXN = 1e6 + 1;
const long long INF = 1e9 + 7;
const long long LINF = 1e18 + 15;
const double EPS = 1e-9;
string s, t;
long long fact[MXN], res, res2, perm = 1, perm2, ans, inv[MXN], invf[MXN];
int used[MXN], id, used2[MXN];
bool used3[MXN], used4[MXN];
inline long long binpow(long long x, long long y) {
  long long result = 1;
  while (y) {
    if (y % 2) {
      result *= x;
      result %= INF;
    }
    x *= x;
    x %= INF;
    y /= 2;
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s >> t;
  fact[0] = 1;
  invf[0] = 1;
  id = s.size();
  for (int i = 1; i < MXN; ++i) {
    fact[i] = fact[i - 1] * i % INF;
    invf[i] = binpow(fact[i], INF - 2) % INF;
  }
  for (int i = 0; i < MXN; ++i) {
    inv[i] = binpow(i * 1LL, INF - 2) % INF;
  }
  for (int i = 0; i < s.size(); ++i) {
    used[s[i]]++;
  }
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != t[i]) {
      id = i;
      break;
    } else {
      used[s[i]]--;
    }
  }
  if (id == s.size()) {
    cout << 0;
    return 0;
  }
  res = fact[s.size() - id];
  for (int i = id; i < s.size(); ++i) {
    if (!used3[s[i]]) {
      perm *= invf[used[s[i]]];
      perm %= INF;
    }
    used3[s[i]] = 1;
  }
  for (char j = s[id] + 1; j < t[id]; ++j) {
    if (!used[j]) {
      continue;
    }
    res *= inv[(long long)s.size() - id];
    res %= INF;
    res *= (long long)used[j];
    res %= INF;
    ans += res * perm;
    ans %= INF;
    res *= ((long long)s.size() - id);
    res %= INF;
    res *= inv[(long long)used[j]];
    res %= INF;
  }
  res2 = res;
  perm2 = perm;
  res *= inv[(long long)s.size() - id];
  res %= INF;
  res *= used[s[id]];
  res %= INF;
  used[s[id]]--;
  for (int i = id + 1; i < s.size(); ++i) {
    for (char j = s[i] + 1; j <= 'z'; ++j) {
      if (!used[j]) {
        continue;
      }
      res *= inv[(long long)s.size() - i];
      res %= INF;
      res *= (long long)used[j];
      res %= INF;
      ans += res * perm;
      ans %= INF;
      res *= ((long long)s.size() - i);
      res %= INF;
      res *= inv[(long long)used[j]];
      res %= INF;
    }
    res *= inv[(long long)s.size() - i];
    res %= INF;
    res *= used[s[i]];
    res %= INF;
    used[s[i]]--;
  }
  for (int i = id; i < s.size(); ++i) {
    used[s[i]]++;
  }
  res = res2;
  perm = perm2;
  if (!used[t[id]]) {
    cout << ans;
    return 0;
  }
  res *= inv[(long long)s.size() - id];
  res %= INF;
  res *= used[t[id]];
  res %= INF;
  used[t[id]]--;
  for (int i = id + 1; i < s.size(); ++i) {
    for (char j = 'a'; j < t[i]; ++j) {
      if (!used[j]) {
        continue;
      }
      res *= inv[(long long)s.size() - i];
      res %= INF;
      res *= used[j];
      res %= INF;
      ans += res * perm;
      ans %= INF;
      res *= ((long long)s.size() - i);
      res %= INF;
      res *= inv[(long long)used[j]];
      res %= INF;
    }
    if (!used[t[i]]) {
      break;
    }
    res *= inv[(long long)s.size() - i];
    res %= INF;
    res *= used[t[i]];
    res %= INF;
    used[t[i]]--;
  }
  cout << ans;
  return 0;
}
