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