#include <bits/stdc++.h>
using namespace std;
bool sortby(const pair<long long, long long> &a,
            const pair<long long, long long> &b) {
  if (a.first == b.first)
    return (a.second > b.second);
  else
    return (a.first > b.first);
}
void solve() {
  long long n, a, b, f = 0, g = 0;
  string x, y;
  cin >> x >> y;
  if (x.size() == y.size()) {
    for (long long i = 0; i < x.size(); i++) {
      if (x[i] == '1') f = 1;
    }
    for (long long i = 0; i < y.size(); i++) {
      if (y[i] == '1') g = 1;
    }
    if (f == g)
      cout << "YES";
    else
      cout << "NO";
  } else
    cout << "NO";
}
signed main() {
  long long t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
}
