#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, res = 0, j, k, len1, len2;
  string line1, line2, line3;
  while (cin >> line1 >> line2) {
    len1 = line1.length();
    len2 = line2.length();
    if (len1 != len2) {
      cout << "NO\n";
      continue;
    }
    int count1 = 0, count2 = 0;
    for (i = 0; i < len1; i++) {
      if (line1[i] == '0') count1++;
      if (line2[i] == '0') count2++;
    }
    if (count1 == len1 || count2 == len2) {
      if (count1 != len1 || count2 != len2) {
        cout << "NO\n";
        continue;
      }
    }
    cout << "YES\n";
  }
  return 0;
}
