#include <bits/stdc++.h>
using namespace std;
map<string, bool> mp;
int main() {
  string a, b;
  cin >> a >> b;
  bool ok = false, ok1 = false;
  int l1 = a.length(), i;
  int l2 = b.length();
  if (a == b) {
    cout << "YES" << endl;
    return 0;
  }
  if (l1 != l2) {
    cout << "NO" << endl;
    return 0;
  }
  for (i = 0; i < l1; i++) {
    if (a[i] == '1') {
      ok = true;
      break;
    }
  }
  for (i = 0; i < l2; i++) {
    if (b[i] == '1') {
      ok1 = true;
      break;
    }
  }
  cout << (ok && ok1 ? "YES" : "NO") << endl;
  return 0;
}
