#include <bits/stdc++.h>
using namespace std;
int main() {
  map<char, int> mp;
  string s;
  cin >> s;
  for (int i = 0; i < 5; i++) {
    string x;
    cin >> x;
    mp[x[0]]++;
    mp[x[1]]++;
  }
  if (mp[s[0]] > 0 || mp[s[1]] > 0)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
