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