#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  bool af = false, bf = false;
  if (a.size() == b.size()) {
    for (int i = 0; i < a.size(); i++) {
      if (a[i] == '1') af = true;
      if (b[i] == '1') bf = true;
    }
    if (a.size() == 1) af = false;
    if (a == b) {
      af = bf = true;
    }
    if (af && bf == true)
      cout << "YES\n";
    else
      cout << "NO\n";
  } else
    cout << "NO\n";
  return 0;
}
