#include <bits/stdc++.h>
const long double eps = 1e-12;
using namespace std;
void solve() {
  string s, t;
  cin >> s >> t;
  bool ok1 = false, ok2 = false;
  if (s.length() != t.length()) {
    cout << "NO";
    return;
  }
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '1') {
      ok1 = true;
    }
  }
  for (int i = 0; i < t.length(); i++) {
    if (t[i] == '1') {
      ok2 = true;
    }
  }
  if (ok1 == ok2) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cout << fixed << setprecision(11);
  int t = 1;
  for (int i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
