#include <bits/stdc++.h>
using namespace std;
bool rnk[13 + 1], st[4];
int hs(char c) {
  if ((int)c >= (int)'2' && (int)c <= (int)'9') return (int)c - (int)'2' + 2;
  if (c == 'T') return 10;
  if (c == 'J') return 11;
  if (c == 'Q') return 12;
  if (c == 'K') return 13;
  if (c == 'A') return 1;
  if (c == 'D') return 0;
  if (c == 'C') return 1;
  if (c == 'S') return 2;
  if (c == 'H') return 3;
}
int main() {
  string input;
  cin >> input;
  rnk[hs(input[0])] = 1;
  st[hs(input[1])] = 1;
  for (int i = 0; i < 5; i++) {
    string str;
    cin >> str;
    if (rnk[hs(str[0])] || st[hs(str[1])]) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
