#include <bits/stdc++.h>
using namespace std;
int main() {
  string str, str1;
  cin >> str;
  long long int i;
  for (i = 1; i <= 5; ++i) {
    cin >> str1;
    if (str1[0] == str[0] || str1[1] == str[1]) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
}
