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