#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  int cnt1[2] = {0}, cnt2[2] = {0};
  for (int i = 0; i < a.length(); i++) {
    ++cnt1[a[i] - '0'];
  }
  for (int i = 0; i < b.length(); i++) {
    ++cnt2[b[i] - '0'];
  }
  if (((int)a.length() != (int)b.length()) || (cnt1[1] == 0 && cnt2[1] > 0) ||
      (cnt1[1] > 0 && cnt2[1] == 0)) {
    cout << "NO";
  } else {
    cout << "YES";
  }
  return 0;
}
