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