#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX_N = 1e6 + 3;
string s, t;
void solve() {
  if (s.length() != t.length()) {
    cout << "NO\n";
    return;
  }
  if (s == t) {
    cout << "YES\n";
    return;
  }
  const int n = s.length();
  if (n == 1 || t == string(n, '0')) {
    cout << "NO\n";
    return;
  }
  for (int i = 0; i < n; ++i)
    if (s[i] == '1') {
      cout << "YES\n";
      return;
    }
  cout << "NO\n";
}
int main() {
  cin >> s >> t;
  solve();
  return 0;
}
