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