#include <bits/stdc++.h>
using namespace std;
int findNextPrimeNum(int num) {
  for (int i = num + 1; 1; i++) {
    bool dec = 1;
    for (int j = 2; j < sqrt(i) + 1; j++) {
      if (i % j == 0) {
        dec = 0;
        break;
      }
    }
    if (dec) {
      return i;
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  if (m == findNextPrimeNum(n)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
