#include <iostream>
#include <cmath>
using namespace std;
bool snt( int n ){
if(n < 2) return 0;
for(int i=2 ; i<=sqrt(n) ; i++){
if(n % i == 0) return 0;
}
return 1;
}
bool tongChuSo ( int n ){
if(!snt(n)) return 0;
int sum = 0;
while( n>0){
sum += n % 10;
n /= 10;
}
if(!snt(sum)) return 0;
return 1;
}
int main() {
int n;
cin>>n;
if(tongChuSo(n)) cout<<"YES."<<endl;
else cout<<"NO"<<endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmJvb2wgc250KCBpbnQgbiApewoJaWYobiA8IDIpIHJldHVybiAwOwoJZm9yKGludCBpPTIgOyBpPD1zcXJ0KG4pIDsgaSsrKXsKCQlpZihuICUgaSA9PSAwKSByZXR1cm4gMDsKCX0KCXJldHVybiAxOwp9Cgpib29sIHRvbmdDaHVTbyAoIGludCBuICl7CiAgICBpZighc250KG4pKSByZXR1cm4gMDsKCWludCBzdW0gPSAwOwoJd2hpbGUoIG4+MCl7CgkJc3VtICs9IG4gJSAxMDsKCQluIC89IDEwOwoJfQoJaWYoIXNudChzdW0pKSByZXR1cm4gMDsKICAgIHJldHVybiAxOwp9CgoKaW50IG1haW4oKSB7CglpbnQgbjsKCWNpbj4+bjsKCWlmKHRvbmdDaHVTbyhuKSkgY291dDw8IllFUy4iPDxlbmRsOwogICAgZWxzZSBjb3V0PDwiTk8iPDxlbmRsOwoJcmV0dXJuIDA7Cn0=