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