#include <bits/stdc++.h>
using namespace std;
char s[20], t[20], x[20];
int n, m, cnt[10], used[10];
inline bool check() {
  memset(used, 0, sizeof used);
  for (int i = 0; i < m; i++)
    if (cnt[t[i] - '0'] > used[t[i] - '0']) {
      x[i] = t[i];
      used[t[i] - '0']++;
    } else {
      int mn = 10;
      for (int j = 0; j < 10; j++)
        if (cnt[j] > used[j]) {
          mn = j;
          break;
        }
      while (t[i] - '0' <= mn)
        if (i) {
          used[x[--i] - '0']--;
          mn = min(mn, x[i] - '0');
        } else
          return false;
      for (int j = t[i] - '1'; ~j; j--)
        if (cnt[j] > used[j]) {
          x[i] = '0' + j;
          used[j]++;
          break;
        }
      for (int j = 9; ~j; j--)
        for (int k = 0; k < cnt[j] - used[j]; k++) x[++i] = '0' + j;
      for (int j = 0; j < m; j++)
        if (s[j] ^ x[j]) return s[j] < x[j];
      break;
    }
  return true;
}
int bt(int p, int sum) {
  if (p > 9) {
    cnt[0] = m - sum;
    return check();
  }
  int ans = 0;
  for (cnt[p] = 0; sum + cnt[p] <= m; cnt[p]++) ans += bt(p + 1, sum + cnt[p]);
  return ans;
}
int main() {
  scanf("%s%s", s, t);
  n = strlen(s), m = strlen(t);
  copy(s, s + n, s + m - n);
  fill(s, s + m - n, '0');
  printf("%d", bt(1, 0));
}
