#include <bits/stdc++.h>
using namespace std;
long long R = pow(10, 9) + 7;
template <typename T>
T last(vector<T>& v) {
  return v[v.size() - 1];
}
template <typename T>
void prll(vector<T>& v) {
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i] << ' ';
  }
  cout << endl;
}
template <typename T1, typename T2>
void prll(vector<pair<T1, T2>>& v) {
  cout << "[";
  for (long long i = 0; i < v.size(); i++) {
    cout << '(' << v[i].first << ',' << v[i].second << "),";
  }
  cout << "]" << endl;
}
template <typename T>
void prll(vector<vector<T>>& v) {
  cout << "[";
  for (long long i = 0; i < v.size(); i++) {
    prll(v[i]);
  }
  cout << "]" << endl;
}
template <typename T>
void prll(set<T>& v) {
  cout << "{";
  for (auto i : v) {
    cout << i << ' ';
  }
  cout << "}" << endl;
}
template <typename T1, typename T2>
void prll(map<T1, T2>& v) {
  cout << "{";
  for (auto i : v) {
    cout << i.first << ':' << i.second << ',';
  }
  cout << "}" << endl;
}
template <typename T>
bool in(set<T>& indices, T x) {
  return indices.find(x) != indices.end();
}
template <typename T, typename T_>
bool in(map<T, T_>& indices, T x) {
  return indices.find(x) != indices.end();
}
long long power(long long x, long long y) {
  long long res = 1;
  x = x % R;
  if (x == 0) return 0;
  while (y > 0) {
    if (y % 2 == 1) res = (res * x) % R;
    y /= 2;
    x = (x * x) % R;
  }
  return res;
}
bool compare(long long a, long long b) { return (a < b); }
long long inverse(long long n) { return power(n, R - 2); }
vector<long long> v(26);
long long val = 0;
long long num = 0;
long long multinomial_coefficient() {
  long long ind = 1;
  long long ans = 1;
  for (long long i = 0; i < v.size(); i++) {
    long long k = v[i];
    long long ans1 = 1;
    for (long long j = 1; j <= k; j++) {
      ans1 *= ind++;
      ans1 %= R;
      ans1 *= inverse(j);
      ans1 %= R;
    }
    ans *= ans1;
    ans %= R;
  }
  return ans;
}
long long solve(string& s) {
  long long n = s.length();
  long long ans = 0;
  bool exit = false;
  for (long long i = 0; i < n; i++) {
    if (exit) break;
    val *= inverse(num);
    val %= R;
    for (long long j = 0; j < 27; j++) {
      if (j == 26) {
        exit = true;
        break;
      }
      if (v[j] == 0) continue;
      char c = j + 'a';
      if (c < s[i]) {
        ans += (val * v[j]);
        ans %= R;
      } else if (c == s[i]) {
        val *= v[j];
        val %= R;
        num--;
        v[j]--;
        break;
      } else {
        exit = true;
        break;
      }
    }
  }
  return ans % R;
}
void TestCase() {
  string s;
  cin >> s;
  string t;
  cin >> t;
  long long n = s.length();
  for (long long i = 0; i < n; i++) {
    v[s[i] - 'a']++;
  }
  val = multinomial_coefficient();
  int val2 = val;
  num = n;
  long long ans1 = solve(s);
  for (long long i = 0; i < 26; i++) v[i] = 0;
  for (long long i = 0; i < n; i++) {
    v[s[i] - 'a']++;
  }
  num = n;
  val = val2;
  long long ans2 = solve(t);
  cout << (ans2 - ans1 - 1 + R) % R << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T;
  T = 1;
  for (long long tt = 1; tt <= T; tt++) {
    TestCase();
  }
}
