#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(51, true);
  v[0] = false;
  v[1] = false;
  for (int i = 2; i <= 50; i++) {
    for (int j = i * i; j <= 50; j += i) {
      v[j] = false;
    }
  }
  for (int i = n + 1; i <= 50; i++) {
    if (v[i] && i == m) {
      cout << "YES" << endl;
      return 0;
    }
    if (v[i] && i != m) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
