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