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