#include <bits/stdc++.h>
using namespace std;

int main()
{
    freopen("numbers.in", "r", stdin);
    freopen("numbers.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    assert(m <= 100000);
    int ans = 0;
    for (int i = 0; i <= m; i++)
    {
        int tmp_n = n;
        int tmp_m = i;
        bool flag = true;
        while (tmp_n > 0) 
        {
            if (tmp_n % 10 != tmp_m % 10)
            {
                flag = false;
                break;
            }
            tmp_n /= 10;
            tmp_m /= 10;
        }
        ans += flag;
    }
    cout << ans << endl;
    return 0;
}