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