#include <bits/stdc++.h>
using namespace std;
int main() {
  int mas[15] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
  int m, n;
  bool ans = false;
  cin >> n >> m;
  for (int i = 0; i < 15; i++) {
    if (mas[i] == n) {
      if (mas[i + 1] == m) {
        ans = true;
        break;
      }
    }
  }
  if (ans)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
