#include<bits/stdc++.h>
using namespace std;
int n,i,m,a[16] = {0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int main(){
cin >> n >> m;
for(i = 1; i < 15; i++){
if(n == a[i]){
if(m == a[i + 1]){
cout<< "YES" << endl;
return 0;
}
cout<< "NO" << endl;
}
}
return 0;
}