#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1;
  string s;
  cin >> s1;
  int c = 0;
  int n = 5;
  while (n--) {
    cin >> s;
    if (s[0] == s1[0] || s[0] == s1[1] || s[1] == s1[1] || s[1] == s1[0]) {
      c++;
    }
  }
  if (c >= 1) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
