#include <bits/stdc++.h>
using namespace std;
int main() {
  char stol[3], ruka[14];
  cin >> stol;
  bool yes = false;
  for (int i = 1; i < 11; i++) {
    cin >> ruka[i];
  }
  for (int i = 1; i < 11; i++) {
    if (!yes) {
      if (i % 2 == 0) {
        if (ruka[i] == stol[1]) yes = true;
      } else {
        if (ruka[i] == stol[0]) yes = true;
      }
    } else
      break;
  }
  if (yes)
    cout << "YES";
  else
    cout << "NO";
}
