#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> hand;
  string table;
  cin >> table;
  string input;
  for (int i = 0; i < 5; ++i) {
    cin >> input;
    hand.push_back(input);
  }
  string answer = "NO";
  for (string card : hand) {
    if (card[0] == table[0] || card[1] == table[1]) {
      answer = "YES";
      break;
    }
  }
  cout << answer;
}
