#include <bits/stdc++.h>
using namespace std;
int a, b, c, i;
string n, m;
int main() {
  cin >> n >> m;
  if (n.size() != m.size()) {
    cout << "NO";
    return 0;
  }
  for (i = 0; i < n.size(); i++) {
    if (n[i] == '1') b++;
    if (m[i] == '1') c++;
  }
  if (b > 0 == c > 0)
    cout << "YES";
  else
    cout << "NO";
}
