#include <bits/stdc++.h>
using namespace std;
bool prime(int br) {
  for (int i = 2; i <= br / 2; i++) {
    if (br % i == 0) return false;
  }
  return true;
}
int main() {
  int a, b;
  cin >> a >> b;
  for (int i = a + 1; i <= b; i++) {
    if (prime(i) && i < b) {
      cout << "NO" << endl;
      return 0;
    } else if (prime(i) && i == b) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
