#include <iostream>
#include<string>
using namespace std;

int main() {
    string str1, str2;
    while (cin >> str1 >> str2) {
        
        if (str2.size() < 5) {
            bool big = false;
            for (int i = 0, j = 0; i < str1.size() - 1;i++) {
                if (str1[i] > str2[0]) {
                    j = i;
                    while (str1[j] == str1[i])j++;
                    if (j - i >= str2.size()) {
                        big = true;
                    }
                    //if (j == str1.size() - 1)break;
                    i = j-1;
                }
            }
            if(big) puts("YES");
            else puts("NO");
        }
        else {
            bool visit[10] = { 0 };
            int res = 0;
            int count = 0;
            int last = -1;
            for (int j = str1.size() - 1; j >= 0; j--) {
                if (!visit[str1[j]-'0'] && str1[j] > str2[0]) {
                    if (last != str1[j] - '0'+1)count = 0;
                    last = str1[j] - '0';
                    count++;
                    res = max(res, count);
                    visit[str1[j] - '0'] = true;
                }
            }
            if (res >= str2.size()) {
                puts("YES");
            }
            else puts("NO");
        }
    }
}
// 64 位输出请用 printf("%lld")