#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s, t;
  cin >> s >> t;
  if (s.length() != t.length() ||
      (s.length() == t.length() && s.length() == 1 && s != t))
    return cout << "NO", 0;
  bool flag = true;
  if (s.find("1") == s.npos && t.find("1") != t.npos) flag = false;
  if (s.find("1") != s.npos && t.find("1") == t.npos) flag = false;
  if (flag)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
