#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  char a, b, x, y;
  scanf("%c%c", &a, &b);
  for (i = 1; i <= 5; i++) {
    cin >> x >> y;
    if (x == a || y == b) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}
