#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1;
  while (TESTS--) {
    string p, q;
    cin >> p;
    cin >> q;
    long long np = p.size();
    long long nq = q.size();
    if (np != nq) {
      cout << "NO";
      return 0;
    }
    long long op = 0, oq = 0;
    for (__typeof(np) i = (0) - ((0) > (np)); i != (np) - ((0) > (np));
         i += 1 - 2 * ((0) > (np)))
      if (p[i] == '1') op++;
    for (__typeof(nq) i = (0) - ((0) > (nq)); i != (nq) - ((0) > (nq));
         i += 1 - 2 * ((0) > (nq)))
      if (q[i] == '1') oq++;
    if (op == 0 && oq > 0) {
      cout << "NO";
    } else if (op == 0) {
      cout << "YES";
    } else if (op > 0 && oq == 0) {
      cout << "NO";
    } else {
      cout << "YES";
    }
  }
  return 0;
}
