#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 922337203685477;
const long long mininf = -922337203685477;
const long long nax = 0;
string a, b;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> a >> b;
  if (a.size() == b.size()) {
    long long ceka = 0, cekb = 0, len = a.size();
    for (long long i = 0; i < len; i++) {
      if (a[i] == '1') {
        ceka = 1;
      }
      if (b[i] == '1') {
        cekb = 1;
      }
    }
    if (ceka && cekb) {
      cout << "YES" << '\n';
      return 0;
    }
  }
  if (a == b) {
    cout << "YES" << '\n';
    return 0;
  } else {
    cout << "NO" << '\n';
  }
}
