#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<pair<char, char>> v;
  char a, b;
  for (int i = 1; i <= 6; i++) {
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  for (int i = 1; i <= 5; i++) {
    if (v[i].first == v[0].first || v[i].second == v[0].second) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
