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