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