#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, M = 1e3 + 10;
string con = "23456789TJQKA";
int in(char x) {
  for (int i = 0; i < con.length(); i++) {
    if (x == con[i]) {
      return i;
    }
  }
}
string s, tmp;
int main() {
  cin >> s;
  for (int i = 0; i <= 4; i += 1) {
    cin >> tmp;
    if (tmp[0] == s[0] || s[1] == tmp[1]) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}
