#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    string a, b;
    cin >> a >> b;
    int ca = 0, cb = 0;
    if ((long long int)a.size() == 1) {
      if (a == b)
        cout << "YES";
      else
        cout << "NO";
      return 0;
    }
    if ((long long int)a.size() != (long long int)b.size()) {
      cout << "NO";
      return 0;
    }
    for (long long int i = 0; i < (long long int)a.size(); i++) {
      if (a[i] == '1') ca++;
      if (b[i] == '1') cb++;
    }
    if (ca == 0) {
      if (cb == 0)
        cout << "YES";
      else
        cout << "NO";
    } else {
      if (cb)
        cout << "YES";
      else
        cout << "NO";
    }
  }
  return 0;
}
