#include <bits/stdc++.h>
using namespace std;
int main() {
  string table;
  string hand;
  getline(cin, table, '\n');
  transform(table.begin(), table.end(), table.begin(), ::tolower);
  getline(cin, hand, '\n');
  transform(hand.begin(), hand.end(), hand.begin(), ::tolower);
  if (hand.find(table[0]) != -1 || hand.find(table[1]) != -1) {
    cout << "YES";
  } else
    cout << "NO";
  return 0;
}
