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