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