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