#include <iostream>
#include <fstream>
using namespace std;
int digitSum(int n, int founded){
int sum_dig = 0;
int found_true = 0;
while(n != 0){
int d = n%10;
if (d == founded){
found_true = 1;
}
n = n/10;
}
if ((n == 0) && (founded == 0)){
found_true = 1;
}
return found_true;
}
int main(){
ifstream fin("in.txt");
ofstream fout("out.txt");
int a, b;
fin >> a >> b;
if ((digitSum(a, b)) == 0){
fout << "NO";
}else{
fout << "YES";
}
fin.close();
fout.close();
}