#include <bits/stdc++.h>
using namespace std;
ofstream fo("test.out");
ifstream fi("test.inp");
int a[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 51};
int n, m;
int main() {
  cin >> n >> m;
  int i = 0;
  while (a[i] != n) {
    i++;
  }
  if (a[i + 1] == m)
    cout << "YES";
  else
    cout << "NO";
}
