#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string onT;
  cin >> onT;
  char onTN = onT[0];
  char onTS = onT[1];
  string temp;
  for (int i = 0; i < 5; i++) {
    cin >> temp;
    char hN = temp[0];
    char hS = temp[1];
    if (hN == onTN || hS == onTS) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
