#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i;
  string s, t;
  cin >> s;
  cin >> t;
  if (s.length() != t.length()) {
    cout << "NO";
    return 0;
  }
  if (s.compare(t) == 0) {
    cout << "YES";
    return 0;
  }
  bool f1, f2, f3, f4;
  f1 = false;
  f2 = false;
  f3 = false;
  f4 = false;
  for (i = 0; i < s.length(); i++) {
    if (s[i] == '1') {
      f1 = true;
    }
    if (s[i] == '0') {
      f2 = true;
    }
  }
  for (i = 0; i < t.length(); i++) {
    if (t[i] == '1') {
      f3 = true;
    }
    if (t[i] == '0') {
      f4 = true;
    }
  }
  if ((f1 == false) || (f3 == false)) {
    cout << "NO";
    return 0;
  }
  cout << "YES";
  return 0;
}
