#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a;
  int x = 5;
  bool flag = false;
  while (x--) {
    cin >> b;
    if (b[0] == a[0] || b[1] == a[1]) flag = true;
  }
  if (flag)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
