#include <bits/stdc++.h>
using namespace std;
int n;
string s[6], S;
bool F;
int main() {
  cin >> S;
  for (int i = 1; i <= 5; ++i) cin >> s[i];
  for (int i = 1; i <= 5; ++i)
    if (s[i][0] == S[0] || s[i][1] == S[1]) F = 1;
  puts(F ? "YES" : "NO");
  return 0;
}
