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