#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, m, x, y, i, j, ans = 0, c = 0, sum = 0;
  string s, t;
  cin >> s >> t;
  if (s.length() != t.length()) {
    cout << "NO\n";
    return;
  }
  if (s.length() == 1) {
    if (s != t)
      cout << "NO\n";
    else
      cout << "YES\n";
    return;
  }
  bool ok = false;
  bool ok1 = false;
  for (i = 0; i < s.length(); i++) {
    if (s[i] == '1') ok = true;
    if (t[i] == '1') ok1 = true;
  }
  if (ok == ok1 || s == t)
    cout << "YES\n";
  else
    cout << "NO\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
