#include <bits/stdc++.h>
using namespace std;
string a, b;
int c[1000000];
int d[1000000];
int cnts[26];
long long ans = 0;
long long facts[1000005];
long long factinv[1000005];
long long modinv(long long a, long long b) {
  long long b0 = b, t, q;
  long long x0 = 0, x1 = 1;
  if (b == 1) return 1;
  while (a > 1) {
    q = a / b;
    t = b, b = a % b, a = t;
    t = x0, x0 = x1 - q * x0, x1 = t;
  }
  if (x1 < 0) x1 += b0;
  return x1;
}
long long sum = 0;
long long prod = 1;
void build() {
  sum = 0;
  prod = 1;
  for (int i = 0; i < (26); ++i) {
    sum += cnts[i];
    prod = (prod * factinv[cnts[i]]) % 1000000007;
  }
  prod = (prod * facts[sum]) % 1000000007;
}
void upd(int idx, int v) {
  long long oldsum = sum;
  long long newsum = (sum + v + 1000000007) % 1000000007;
  long long oldfactor = cnts[idx];
  long long newfactor = cnts[idx] + v;
  prod = (prod * factinv[oldsum]) % 1000000007;
  prod = (prod * facts[newsum]) % 1000000007;
  prod = (prod * facts[oldfactor]) % 1000000007;
  prod = (prod * factinv[newfactor]) % 1000000007;
  cnts[idx] = (cnts[idx] + v + 1000000007) % 1000000007;
  sum = newsum;
}
int n;
int dup[26];
int main() {
  facts[0] = 1;
  factinv[0] = 1;
  for (int i = 1; i <= 1000000; i++) {
    facts[i] = (facts[i - 1] * i) % 1000000007;
    factinv[i] = modinv(facts[i], 1000000007);
  }
  cin >> a >> b;
  n = a.length();
  for (int i = 0; i < (n); ++i) c[i] = a[i] - 'a';
  for (int i = 0; i < (n); ++i) d[i] = b[i] - 'a';
  for (int i = 0; i < (n); ++i) cnts[c[i]]++;
  int ptr = 0;
  while (c[ptr] == d[ptr]) {
    cnts[c[ptr]]--;
    ptr++;
  }
  build();
  assert(ptr < n);
  for (int i = 0; i < (26); ++i) dup[i] = cnts[i];
  for (int nxt = c[ptr] + 1; nxt <= d[ptr] - 1; nxt++) {
    if (cnts[nxt] == 0) continue;
    upd(nxt, -1);
    ans = (ans + prod) % 1000000007;
    upd(nxt, 1);
  }
  for (int i = ptr; i < n - 1; i++) {
    if (cnts[c[i]] < 1) break;
    upd(c[i], -1);
    for (int nxt = c[i + 1] + 1; nxt <= 25; nxt++) {
      if (cnts[nxt] == 0) continue;
      upd(nxt, -1);
      ans = (ans + prod) % 1000000007;
      upd(nxt, 1);
    }
  }
  for (int i = 0; i < (26); ++i) cnts[i] = dup[i];
  build();
  for (int i = ptr; i < n - 1; i++) {
    if (cnts[d[i]] < 1) break;
    upd(d[i], -1);
    for (int nxt = 0; nxt <= d[i + 1] - 1; nxt++) {
      if (cnts[nxt] == 0) continue;
      upd(nxt, -1);
      ans = (ans + prod) % 1000000007;
      upd(nxt, 1);
    }
  }
  cout << ans << endl;
}
