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