#include <bits/stdc++.h>
using namespace std;
bool Is2n(int n) {
  if (n <= 0) return false;
  if ((n & ((~n) + 1)) == n)
    return true;
  else
    return false;
}
int gcd(int a, int b) {
  int c;
  while (a != 0) {
    c = a;
    a = b % a;
    b = c;
  }
  return b;
}
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
int main() {
  string a, b;
  cin >> a >> b;
  if (a == b) {
    cout << "YES";
    return 0;
  } else if (a.size() != b.size() || (a.size() == 1 && b.size() == 1)) {
    cout << "NO";
    return 0;
  } else {
    bool A, B;
    A = B = false;
    for (int i = int(0); i < int(a.size()); i++) {
      A = A | (a[i] == '1');
      B = B | (b[i] == '1');
    }
    if (A && B)
      cout << "YES";
    else
      cout << "NO";
    return 0;
  }
  return 0;
}
