#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int temp = 1;
  for (int i = 0; i < 5; i++) {
    string p;
    cin >> p;
    if (p[0] == s[0] || p[1] == s[1]) {
      cout << "YES";
      temp = 0;
      break;
    }
  }
  if (temp != 0) cout << "NO";
  return 0;
}
