#include <bits/stdc++.h>
int const N = 2005, M = 1005;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string a, b;
  cin >> a >> b;
  if (a.size() != b.size()) return cout << "NO", 0;
  bool yes = true, yes1 = true;
  for (int i = 0; i < a.size(); i++)
    yes &= (a[i] == '0'), yes1 &= (b[i] == '0');
  if ((yes && !yes1) || (!yes && yes1)) return cout << "NO", 0;
  cout << "YES";
  return 0;
}
