#include <bits/stdc++.h>
using namespace std;
template <class T>
typename T::value_type arr_sum(const T& v, int n) {
  typename T::value_type sum = 0;
  for (int i = (0); i < (n); ++i) sum += v[i];
  return sum;
}
struct Sync_stdio {
  Sync_stdio() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
  }
} _sync_stdio;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  if (s1.size() != s2.size()) {
    cout << "NO";
    return 0;
  }
  cout << (((count(s1.begin(), s1.end(), '0') == s1.size()) ^
            (count(s2.begin(), s2.end(), '0') == s2.size()))
               ? "NO"
               : "YES");
}
