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