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