#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  if ((int)s1.size() != (int)s2.size())
    cout << "NO" << endl;
  else if (s1 == s2)
    cout << "YES" << endl;
  else if ((int)s1.size() == 1)
    cout << "NO" << endl;
  else {
    bool v = false;
    for (int i = int(0); i < int((int)s1.size()); i++)
      if (s1[i] != '0') v = true;
    bool vv = false;
    for (int i = int(0); i < int((int)s2.size()); i++)
      if (s2[i] != '0') vv = true;
    if (v) {
      if (vv)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
