#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long power(long long a, long long b, long long m = 1000000007) {
  long long answer = 1;
  while (b) {
    if (b & 1) answer = (answer * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return answer;
}
using namespace std;
void ctrl() { cout << "Control" << endl; }
int make_num(string p) {
  stringstream geek(p);
  int x = 0;
  geek >> x;
  return x;
}
string make_str(int x) {
  ostringstream str1;
  str1 << x;
  string geek = str1.str();
  return geek;
}
long long fact[1000000 + 5], inv[1000000 + 5];
const int L = 100;
long long cal(string a, string b) {
  int cnt[26];
  for (int i = 0; i < 26; i++) cnt[i] = 0;
  for (int i = 0; i < a.length(); i++) {
    int x = a[i] - 'a';
    cnt[x]++;
  }
  long long ans = 0;
  for (int i = 0; i < b.length(); i++) {
    long long val = 1;
    for (int k = 0; k < 26; k++) val = (val * inv[cnt[k]]) % 1000000007;
    for (int j = 0; j < b[i] - 'a'; j++) {
      if (cnt[j] == 0) continue;
      long long fk = inv[cnt[j] - 1];
      fk = (fk * fact[cnt[j]]) % 1000000007;
      fk = (fk * val) % 1000000007;
      fk = (fk * fact[b.length() - 1 - i]) % 1000000007;
      ans = (ans + fk) % 1000000007;
    }
    if (cnt[b[i] - 'a'] == 0) break;
    cnt[b[i] - 'a']--;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  string p, q;
  cin >> p >> q;
  fact[0] = 1;
  for (int i = 1; i <= 1000000; i++) {
    long long h = (fact[i - 1] * 1LL * i);
    h = h % 1000000007;
    fact[i] = h % 1000000007;
  }
  inv[1000000] = power(fact[1000000], 1000000007 - 2, 1000000007);
  for (int i = 1000000 - 1; i >= 0; i--) {
    long long h = (inv[i + 1] * 1LL * (i + 1)) % 1000000007;
    inv[i] = h;
  }
  long long val = cal(p, q) - cal(p, p);
  val--;
  while (val < 0) val += 1000000007;
  cout << val;
  return 0;
}
