#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void chkmin(T1 &x, T2 y) {
  if (x > y) x = y;
}
template <typename T1, typename T2>
inline void chkmax(T1 &x, T2 y) {
  if (x < y) x = y;
}
inline long long readChar();
template <class T = long long>
inline T readInt();
template <class T>
inline void writeInt(T x, char end = 0);
inline void writeChar(long long x);
inline void writeWord(const char *s);
static const long long buf_size = 4096;
inline long long getChar() {
  static char buf[buf_size];
  static long long len = 0, pos = 0;
  if (pos == len) {
    pos = 0, len = fread(buf, 1, buf_size, stdin);
  }
  if (pos == len) {
    return -1;
  }
  return buf[pos++];
}
inline long long readChar() {
  long long c = getChar();
  while (c <= 32) {
    c = getChar();
  }
  return c;
}
template <class T>
inline T readInt() {
  long long s = 1, c = readChar();
  T x = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return s == 1 ? x : -x;
}
static long long write_pos = 0;
static char write_buf[buf_size];
inline void writeChar(long long x) {
  if (write_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
  write_buf[write_pos++] = x;
}
template <class T>
inline void writeInt(T x, char end) {
  if (x < 0) writeChar('-'), x = -x;
  char s[24];
  long long n = 0;
  while (x || !n) s[n++] = '0' + x % 10, x /= 10;
  while (n--) writeChar(s[n]);
  if (end) writeChar(end);
}
inline void writeWord(const char *s) {
  while (*s) writeChar(*s++);
}
struct Flusher {
  ~Flusher() {
    if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
  }
} flusher;
const string FILENAME = "input";
const int Mod = 1000000007;
const int MAXN = 1000002;
int powm(int a, int b) {
  if (b == 0) {
    return 1;
  } else if (b & 1) {
    int s = powm(a, b - 1);
    return (1LL * s * a) % Mod;
  } else {
    int s = powm(a, b >> 1);
    return (1LL * s * s) % Mod;
  }
}
string a, b;
int cnt[26], cnt1[26];
int fact[MAXN];
int rfact[MAXN];
int get(string s) {
  int ans = 0;
  for (char st = 'a'; st < s[0]; st++) {
    if (cnt[st - 'a']) {
      cnt[st - 'a']--;
      int sum = 0;
      int res = 1;
      for (int i = 0; i < 26; i++) {
        sum += cnt[i];
        res = (1LL * res * rfact[cnt[i]]) % Mod;
      }
      res = (1LL * res * fact[sum]) % Mod;
      cnt[st - 'a']++;
      ans += res;
      ans %= Mod;
    }
  }
  for (int i = 0; i < 26; i++) {
    cnt1[i] = cnt[i];
  }
  for (int i = 0; i < (long long)(s).size(); i++) {
    if (i) {
      int sum = 0;
      int res = 1;
      for (int is = 0; is < 26; is++) {
        sum += cnt1[is];
        res = (1LL * res * rfact[cnt1[is]]) % Mod;
      }
      sum--;
      res = (1LL * res * fact[sum]) % Mod;
      for (char st = 'a'; st < s[i]; st++) {
        if (cnt1[st - 'a']) {
          int res1 = res;
          res1 = (1LL * res1 * fact[cnt1[st - 'a']]) % Mod;
          res1 = (1LL * res1 * rfact[cnt1[st - 'a'] - 1]) % Mod;
          ans += res1;
          ans %= Mod;
        }
      }
    }
    cnt1[s[i] - 'a']--;
    if (cnt1[s[i] - 'a'] < 0) {
      break;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> a >> b;
  fact[0] = 1;
  for (int i = 1; i <= 1000000; i++) {
    fact[i] = (1LL * fact[i - 1] * i) % Mod;
  }
  rfact[1000000] = powm(fact[1000000], Mod - 2);
  rfact[0] = 1;
  for (int i = 999999; i >= 1; i--) {
    rfact[i] = (1LL * rfact[i + 1] * (i + 1)) % Mod;
  }
  for (auto c : a) {
    cnt[c - 'a']++;
  }
  cout << (get(b) - get(a) - 1 + Mod) % Mod << endl;
  return 0;
}
