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