#include <bits/stdc++.h>
using namespace std;
void Solve() {
  int n, m;
  cin >> n >> m;
  bool okay = false;
  for (int i = (n + 1); i < m + 1; i++) {
    if (i == 3 || i == 5 || i == 7) {
      okay = i == m;
      break;
    }
    if (i % 2 == 0 || i % 3 == 0 || i % 5 == 0 || i % 7 == 0) {
      continue;
    } else {
      okay = i == m;
      break;
    }
  }
  if (okay) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
int main() {
  Solve();
  return 0;
}
