#include <bits/stdc++.h>
using namespace std;
int main() {
  string S, a[6];
  cin >> S;
  for (int k = 1; k <= 5; k++) cin >> a[k];
  for (int k = 1; k <= 5; k++)
    if (a[k][0] == S[0] || a[k][1] == S[1]) {
      cout << "YES";
      return 0;
    }
  cout << "NO";
  return 0;
}
