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