#include <bits/stdc++.h>
using namespace std;
string a, b;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> b;
  if (a.size() != b.size()) return cout << "NO" << endl, 0;
  bool ok1 = false, ok2 = false;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == '1') ok1 = true;
    if ((a[i] == '1' && b[i] == '1') || a[i] == '0' && b[i] == '1') ok2 = true;
  }
  bool yes = true;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == '1' && b[i] == '0') yes &= ok2;
    if (a[i] = '0' && b[i] == '1') yes &= ok1;
  }
  if (yes)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
