#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  if (s1.size() != s2.size()) {
    cout << "NO";
    return 0;
  }
  int f = 0, s = 0;
  for (char a : s1)
    if (a == '1') ++f;
  for (char a : s2)
    if (a == '1') ++s;
  if (f > 0 && s > 0) {
    cout << "YES\n";
  } else if (f == 0 && s == 0) {
    cout << "YES\n";
  } else
    cout << "NO";
}
