#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  string com;
  cin >> com;
  string s[5];
  for (int i = 0; i < 5; i++) {
    cin >> s[i];
    if (s[i][0] == com[0] || s[i][1] == com[1]) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}
