#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print_array(const T &arr, char c = ' ') {
  for (auto x : arr) {
    cout << x << c;
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s, r;
  cin >> s >> r;
  if (s.size() == r.size()) {
    bool s1 = 0, r1 = 0;
    for (long long i = 0; i < s.length(); i++) {
      if (s[i] == '1') s1 = 1;
      if (r[i] == '1') r1 = 1;
    }
    if (s == r) {
      s1 = 1;
      r1 = 1;
    }
    if (s1 && r1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
