#include<iostream>
#include<algorithm>

using namespace std;

int puta10na(unsigned long long int x, int y) {        //vraca x * 10^y

	for (int i = 0; i < y; i++) {
		x = x * 10;
	}
	return x;
}

int br_cifara(int x) {

	int brojac = 0;

	while (x > 0) {
		x = x / 10;
		brojac++;
	}
	return brojac;
}

int main() {

	int x, y, n, xl, yl;
	cin >> x >> y;

	xl = br_cifara(x);
	yl = br_cifara(y);

	n = 0;
	int brojac = 0;

	for (int i = 0; i < min(xl, yl); i++) {
		if (x / puta10na(1, i) % 10 == (y / puta10na(1, i)) % 10) {
			n += ((x / puta10na(1, i)) % 10) * puta10na(1, br_cifara(n)) + ((x / puta10na(1, i)) % 10) * puta10na(1, br_cifara(n) + 1);
			brojac++;
		}
		else {
			n += max((x / puta10na(1, i)) % 10, (y / puta10na(1, i)) % 10) * puta10na(1, br_cifara(n));
		}
	}

	n += max(x, y) / puta10na(1, min(xl, yl)) * puta10na(1, min(xl, yl) + brojac);

	cout << n << endl;

	return 0;
}