#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  string str1, str2;
  cin >> str1 >> str2;
  int l1 = str1.length();
  int l2 = str2.length();
  if (l1 != l2 || (l1 == 1 && l2 == 1 && str1 != str2)) {
    cout << "NO";
    return 0;
  }
  int a = 0, b = 0;
  for (i = 0; i <= l1 - 1; ++i) {
    if (str1[i] == '1') ++a;
    if (str2[i] == '1') ++b;
  }
  if ((a == 0 && b > 0) || (a > 0 && b == 0))
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
