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