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