#include <bits/stdc++.h>
const int maxN = (int)1e4 + 7;
const int maxM = (int)1e5 + 7;
const int maxT = (int)1e6 + 7;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string s, p;
  cin >> s >> p;
  if (s.length() != p.length())
    cout << "NO";
  else {
    if ((s.find('1') != -1 && p.find('1') != -1) || s == p)
      cout << "YES";
    else
      cout << "NO";
  }
}
