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