#include <bits/stdc++.h>
using namespace std;
int main() {
  string A, B;
  cin >> A >> B;
  int L1 = A.length(), L2 = B.length();
  if (L1 != L2) {
    cout << "NO";
    return 0;
  }
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < L1; i++) {
    if (A[i] == '1') {
      cnt1++;
    }
    if (B[i] == '1') {
      cnt2++;
    }
  }
  if ((cnt2 == 0 and cnt1 != 0) or (cnt1 == 0 and cnt2 != 0)) {
    cout << "NO";
    return 0;
  } else {
    cout << "YES";
    return 0;
  }
}
