#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = (long long)1000000007 * 1000000007;
const double EPS = 1e-9;
int main() {
  string s, t;
  cin >> s >> t;
  int len = s.length();
  bool f = false;
  for (int i = 0; i < len; i++) {
    if (s[i] == t[i]) f = true;
  }
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
