#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  string a, b;
  cin >> a >> b;
  if (a.size() == b.size()) {
    int ca = 0, cb = 0;
    for (int i = 0; i < a.size(); i++) {
      ca += a[i] == '1';
      cb += b[i] == '1';
    }
    if (!ca && cb || ca && !cb)
      cout << "NO";
    else
      cout << "YES";
  } else
    cout << "NO";
  return 0;
}
