#include <bits/stdc++.h>
using namespace std;
int main() {
  int mark = 0;
  string s1, s2;
  int n = 5;
  cin >> s1;
  while (n--) {
    cin >> s2;
    if (s1[0] == s2[0] || s1[1] == s2[1]) {
      mark++;
    }
  }
  if (mark == 0) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
}
