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

// 统计 x 中数字 k 出现次数
int cntDigit(long long x, long long k) {
    int c = 0;
    while (x) {
        c += (x % 10 == k);
        x /= 10;
    }
    return c;
}

int main() {
    int n, k;
    cin >> n >> k;
    long long a = 1, b = 1;                // Fib1=1, Fib2=1
    int bestCnt = -1;
    long long ans = LLONG_MAX;

    for (int i = 1; i <= n; ++i) {
        long long x;
        if (i <= 2) x = 1;
        else {
            x = a + b;
            a = b;
            b = x;
        }

        int c = cntDigit(x, k);
        if (c > bestCnt || (c == bestCnt && x < ans)) {
            bestCnt = c;
            ans = x;
        }
    }
    cout << ans << '\n';
    return 0;
}