#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  string s;
  cin >> s;
  bool ok = false;
  for (long long i = 0; i < 5; i++) {
    string x;
    cin >> x;
    if (s[0] == x[0]) {
      ok = true;
      break;
    }
    if (s[1] == x[1]) {
      ok = true;
      break;
    }
  }
  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
