#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m, x, i, cnt = 0, count = 0;
  int z[19] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
  cin >> n >> m;
  for (i = 0; i < 14; i++) {
    if (n == z[i] && m == z[i + 1]) {
      cnt = 2;
    }
  }
  if (cnt == 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
