#include <bits/stdc++.h>
using namespace std;
int a, d[101], b, f, g, h, j, k, l, n, i;
string s, x;
int main() {
  cin >> s >> x;
  a = s.size();
  b = x.size();
  if (s == x) {
    cout << "YES";
    return 0;
  }
  if (a != b) {
    cout << "NO";
    return 0;
  }
  for (i = 0; i < a; i++) {
    if (s[i] == '1') {
      k++;
    }
    if (x[i] == '1') {
      j++;
    }
  }
  if (k > 0 && j > 0)
    cout << "YES";
  else
    cout << "NO";
}
