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