#include <bits/stdc++.h>
using namespace std;
bool is(string s) {
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '1') return true;
  }
  return false;
}
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  if (!(s1.length() == s2.length()))
    cout << "NO";
  else {
    if ((is(s1) && !is(s2)) || (is(s2) && !is(s1)))
      cout << "NO";
    else
      cout << "YES";
  }
  return 0;
}
