#include<bits/stdc++.h>
using namespace std;
int snt(int n){
if(n<2) return 0;
for(int i=2;i*i<=n;i++){
if(n%i==0) return 0;
}
return 1;
}
int main(){
int k,x;
cin>>k>>x;
bool a=true;
int dem=0;
int luu=k;
if(!snt(k)) a=false;
while(k!=0){
dem++;
k/=10;
}
if(dem!=x) a=false;
int tong=0;
while(luu!=0){
tong+=(luu%10);
if(!snt(luu%10)) a=false;
luu/=10;
}
if(!snt(tong)) a=false;
if(a) cout<<"YES";
else cout<<"NO";
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IHNudChpbnQgbil7CglpZihuPDIpIHJldHVybiAwOwoJZm9yKGludCBpPTI7aSppPD1uO2krKyl7CgkJaWYobiVpPT0wKSByZXR1cm4gMDsKCX0KCXJldHVybiAxOwp9CmludCBtYWluKCl7CglpbnQgayx4OwoJY2luPj5rPj54OwoJYm9vbCBhPXRydWU7CglpbnQgZGVtPTA7CglpbnQgbHV1PWs7CglpZighc250KGspKSBhPWZhbHNlOyAKCXdoaWxlKGshPTApewoJCWRlbSsrOwoJCWsvPTEwOwoJfQoJaWYoZGVtIT14KSBhPWZhbHNlOwoJaW50IHRvbmc9MDsKCXdoaWxlKGx1dSE9MCl7CgkJdG9uZys9KGx1dSUxMCk7CgkJaWYoIXNudChsdXUlMTApKSBhPWZhbHNlOwoJCWx1dS89MTA7Cgl9CglpZighc250KHRvbmcpKSBhPWZhbHNlOwoJaWYoYSkgY291dDw8IllFUyI7CgllbHNlIGNvdXQ8PCJOTyI7Cn0=