#include <bits/stdc++.h>
using namespace std;
int main() {
  string n, s;
  cin >> s;
  for (int i = 0; i <= 4; i++) {
    cin >> n;
    if (s[0] == n[0] || s[1] == n[1]) {
      cout << "YES";
      exit(0);
    }
  }
  cout << "NO";
}
