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