#include <bits/stdc++.h>
using namespace std;
long long fun(long long N, long long P) {
  if (P == 0) return 1;
  if (P % 2 == 0) {
    long long ret = fun(N, P / 2);
    return ((ret % 1000000007) * (ret % 1000000007)) % 1000000007;
  } else
    return ((N % 1000000007) * (fun(N, P - 1) % 1000000007)) % 1000000007;
}
bool isValid(char ch) {
  string s = "DCSH";
  for (int i = 0; i < s.size(); i++) {
    if (ch == s[i]) {
      return 1;
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  string s;
  while (cin >> s) {
    string tm;
    long long ans = 0;
    for (int i = 1; i <= 5; i++) {
      cin >> tm;
      if (tm[0] == s[0] || tm[1] == s[1]) {
        ans = 1;
      }
    }
    if (ans == 1) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
