#include <bits/stdc++.h>
using namespace std;
char src[1000005], dst[1000005];
int jichang[1000005], inv[1000005];
static inline int n2p(int n, int p) {
  int r = 1;
  while (p) {
    long long t = n;
    if (p % 2 == 0) {
      n = (t * t) % 1000000007;
      p /= 2;
    } else {
      r = (r * t) % 1000000007;
      p -= 1;
    }
  }
  return r;
}
static inline int calc(char *s, int l, int *c) {
  long long t, tn;
  int i, j, r = 0;
  for (i = 0; i < l; i++) {
    tn = jichang[l - i - 1];
    for (j = 0; j < 26; j++) {
      tn = (tn * inv[c[j]]) % 1000000007;
    }
    for (j = 0; j < s[i] - 'a'; j++) {
      if (c[j] == 0) continue;
      t = (tn * jichang[c[j]]) % 1000000007;
      r = (r + t * inv[c[j] - 1]) % 1000000007;
    }
    if (c[s[i] - 'a'] == 0) break;
    c[s[i] - 'a']--;
  }
  return r;
}
int main() {
  int l, r, i, cnt1[26], cnt2[26];
  scanf("%s%s", src, dst);
  l = strlen(src);
  jichang[0] = jichang[1] = inv[0] = inv[1] = 1;
  for (i = 2; i <= l; i++) {
    long long t = i;
    jichang[i] = (t * jichang[i - 1]) % 1000000007;
    t = n2p(i, 1000000007 - 2);
    inv[i] = (t * inv[i - 1]) % 1000000007;
  }
  memset(cnt1, 0, sizeof(cnt1));
  for (i = 0; i < l; i++) cnt1[src[i] - 'a']++;
  memcpy(cnt2, cnt1, sizeof(cnt1));
  r = calc(dst, l, cnt1);
  r = (r - calc(src, l, cnt2) - 1 + 1000000007) % 1000000007;
  printf("%d\n", r);
  return 0;
}
