#include <bits/stdc++.h>
using namespace std;
string s;
string d;
bool check = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  for (int i = 0; i < 5; i++) {
    cin >> d;
    if (d[0] == s[0] || d[1] == s[1]) check = 1;
  }
  if (check)
    cout << "YES";
  else
    cout << "NO";
}
