#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, cot = 0, i, j;
  cin >> n >> t;
  for (i = n + 1; i <= t; i++) {
    cot = 0;
    for (j = i; j >= 1; j--) {
      if (i % j == 0) cot++;
    }
    if (cot == 2 && t == i) {
      cout << "YES";
      return 0;
    } else if (cot == 2 && t != i) {
      cout << "NO";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
