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