#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  char k[14];
  cin >> n;
  for (int i = 0; i < 10; i++) {
    cin >> k[i];
  }
  for (int i = 0; i < 10; i++) {
    if ((n[1] == k[i]) || (n[0] == k[i])) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
