#include <bits/stdc++.h>
using namespace std;
int main() {
  char table[10];
  int flag = 0;
  scanf("%s", table);
  for (int i = 0; i < 5; i++) {
    char hand[10];
    scanf("%s", hand);
    if (hand[0] == table[0] || hand[1] == table[1]) {
      printf("YES\n");
      flag = 1;
      break;
    }
  }
  if (flag == 0) printf("NO\n");
  return 0;
}
