#include <bits/stdc++.h>
using namespace std;
char a[1001], b[1001], ch1, ch2;
int aa[1009], bb[1009];
int main() {
  cin >> a >> b;
  for (int i = 0; i < strlen(a); ++i)
    if (i == 0)
      ch1 = a[i];
    else
      ch1 = max(ch1, a[i]);
  for (int i = 0; i < strlen(b); ++i)
    if (i == 0)
      ch2 = b[i];
    else
      ch2 = max(ch2, b[i]);
  ++ch1;
  ++ch2;
  if (ch1 == ':') ch1 = 'A';
  if (ch2 == ':') ch2 = 'A';
  for (int i = 0; i < strlen(a); ++i) {
    if (a[i] <= '9' && a[i] >= '0')
      aa[strlen(a) - i - 1] = (int)a[i] - (int)'0';
    if (a[i] <= 'Z' && a[i] >= 'A')
      aa[strlen(a) - i - 1] = (int)a[i] - (int)'A' + 10;
  }
  for (int i = 0; i < strlen(b); ++i) {
    if (b[i] <= '9' && b[i] >= '0')
      bb[strlen(b) - i - 1] = (int)b[i] - (int)'0';
    if (b[i] <= 'Z' && b[i] >= 'A')
      bb[strlen(b) - i - 1] = (int)b[i] - (int)'A' + 10;
  }
  int kol = 0;
  if (ch1 <= '9' && ch1 >= '0') kol = (int)ch1 - (int)'0';
  if (ch1 <= 'Z' && ch1 >= 'A') kol = (int)ch1 - (int)'A' + 10;
  if (ch2 <= '9' && ch2 >= '0') kol = max(kol, (int)ch2 - (int)'0');
  if (ch2 <= 'Z' && ch2 >= 'A') kol = max(kol, (int)ch2 - (int)'A' + 10);
  int maxx = max(strlen(a), strlen(b));
  int c = 0;
  for (int i = 0; i < maxx; ++i) {
    c = c + aa[i] + bb[i];
    aa[i] = c % kol;
    c = c / kol;
  }
  if (c > 0) {
    aa[maxx] = c;
    ++maxx;
  }
  cout << maxx;
  return 0;
}
