#include <bits/stdc++.h>
using namespace std;
string s1, s2;
long long l1, l2;
long long k1, k2, i;
int main() {
  cin >> s1 >> s2;
  l1 = s1.length();
  l2 = s2.length();
  if (l1 != l2) {
    cout << "NO";
  } else {
    if (s1 == s2) {
      cout << "YES";
    } else {
      i = 0;
      while (i < l1) {
        if (s1[i] == '1') {
          k1++;
        }
        i++;
      }
      i = 0;
      while (i < l2) {
        if (s2[i] == '1') {
          k2++;
        }
        i++;
      }
      if (k1 > 0 && k2 > 0) {
        cout << "YES";
      } else {
        cout << "NO";
      }
    }
  }
  return 0;
}
