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