#include <bits/stdc++.h>
using namespace std;
char a[1000005], b[1000005];
int n, cnt[26], c[26], f[1000005], rf[1000005], sr[1000005];
int f1(char *s) {
  memcpy(c, cnt, sizeof(c));
  int i, x, now, ans = 0, cur = f[n];
  for (i = 0; i < 26; i++) {
    if (c[i]) cur = 1ll * cur * rf[c[i]] % 1000000007;
  }
  for (i = 1; i <= n; i++) {
    for (x = 0; x < s[i] - 'a'; x++) {
      if (c[x]) {
        now = cur;
        now = 1ll * now * sr[n - i + 1] % 1000000007;
        now = 1ll * now * c[x] % 1000000007;
        ans = (ans + now) % 1000000007;
      }
    }
    if (c[s[i] - 'a']) {
      cur = 1ll * cur * sr[n - i + 1] % 1000000007;
      cur = 1ll * cur * c[s[i] - 'a'] % 1000000007;
      c[s[i] - 'a']--;
    } else
      break;
  }
  return ans;
}
int rev(int a) {
  int b, ret = 1;
  for (b = 1000000007 - 2; b; b >>= 1, a = 1ll * a * a % 1000000007)
    if (b & 1) ret = 1ll * ret * a % 1000000007;
  return ret;
}
int main() {
  int i;
  f[0] = rf[0] = 1;
  for (i = 1; i <= 1000000; i++) {
    f[i] = 1ll * i * f[i - 1] % 1000000007;
    sr[i] = rev(i);
    rf[i] = 1ll * sr[i] * rf[i - 1] % 1000000007;
  }
  cin >> a + 1 >> b + 1;
  n = strlen(a + 1);
  for (i = 1; i <= n; i++) cnt[a[i] - 'a']++;
  cout << (f1(b) - f1(a) - 1 + 1000000007) % 1000000007 << endl;
  return 0;
}
