#include <bits/stdc++.h>
using namespace std;
#pragma gcc optimize("ofast");
#pragma g++ optimize("ofast");
string str, res, a;
bool s;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> a;
  for (int i = int(0); i < int(5); i++) {
    cin >> str;
    if (str[0] == a[0] || str[1] == a[1]) s = 1;
  }
  s ? res = "YES" : res = "NO";
  return cout << res << '\n', 0;
}
