#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char** argv) {
  string s1, s2;
  cin >> s1 >> s2;
  if (s1.length() != s2.length()) {
    cout << "NO" << endl;
    return 0;
  }
  int k1 = 0, k2 = 0;
  for (int i = 0; i < s1.size(); i++) {
    if (s1[i] == '1') k1 = 1;
    if (s2[i] == '1') k2 = 1;
  }
  string res = (k1 == k2) ? "YES" : "NO";
  cout << res << endl;
  return 0;
}
