#include <bits/stdc++.h>
using namespace std;
int ok1(int k, int n){
int cnt = 0;
while(k!=0){
++cnt;
k /= 10;
}
if(cnt == n) return 1;
else return 0;
}
int ok2(int k){
if(k<2) return 0;
for(int i = 2; i <= sqrt(k); i++){
if(k%i==0) return 0;
}
return 1;
}
int ok3(int k){
int sum = 0;
while(k!=0){
sum += k % 10;
k /= 10;
}
if(ok2(sum)) return 1;
else return 0;
}
int ok4(int k){
while(k!=0){
int x = k % 10;
if(ok2(x)==0) return 0;
k /= 10;
}
return 1;
}
int main(){
int k, n;
cin >> k >> n;
if(ok1(k,n) && ok2(k) && ok3(k) && ok4(k)) cout << "Yes";
else cout << "No";
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgb2sxKGludCBrLCBpbnQgbil7CglpbnQgY250ID0gMDsKCXdoaWxlKGshPTApewoJCSsrY250OwoJCWsgLz0gMTA7Cgl9CglpZihjbnQgPT0gbikgcmV0dXJuIDE7CgllbHNlIHJldHVybiAwOwp9CgppbnQgb2syKGludCBrKXsKCWlmKGs8MikgcmV0dXJuIDA7Cglmb3IoaW50IGkgPSAyOyBpIDw9IHNxcnQoayk7IGkrKyl7CgkJaWYoayVpPT0wKSByZXR1cm4gMDsKCX0KCXJldHVybiAxOwp9CgppbnQgb2szKGludCBrKXsKCWludCBzdW0gPSAwOwoJd2hpbGUoayE9MCl7CgkJc3VtICs9IGsgJSAxMDsKCQlrIC89IDEwOwoJfQoJaWYob2syKHN1bSkpIHJldHVybiAxOwoJZWxzZSByZXR1cm4gMDsKfQoKaW50IG9rNChpbnQgayl7Cgl3aGlsZShrIT0wKXsKCQlpbnQgeCA9IGsgJSAxMDsKCQlpZihvazIoeCk9PTApIHJldHVybiAwOwoJCWsgLz0gMTA7Cgl9CglyZXR1cm4gMTsKfQoKaW50IG1haW4oKXsKCWludCBrLCBuOwoJY2luID4+IGsgPj4gbjsKCWlmKG9rMShrLG4pICYmIG9rMihrKSAmJiBvazMoaykgJiYgb2s0KGspKSBjb3V0IDw8ICJZZXMiOwoJZWxzZSBjb3V0IDw8ICJObyI7CgkKCQp9