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