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