#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n{}, m{};
  cin >> n >> m;
  int arr[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
  cout << (*(lower_bound(arr, arr + 15, n) + 1) == m ? "YES" : "NO") << "\n";
  return 0;
}
