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