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