#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  string a, b;
  int fa = 0, fb = 0;
  cin >> a;
  cin >> b;
  for (char x : a) {
    if (x == '1') fa = 1;
  }
  for (char x : b) {
    if (x == '1') fb = 1;
  }
  if (a == b)
    cout << "YES";
  else if (a.length() != b.length() || fa == 0 || fb == 0) {
    cout << "NO";
  } else
    cout << "YES";
  return 0;
}
