#include <bits/stdc++.h>
using namespace std;
signed main() {
  string a, b;
  cin >> a >> b;
  if (a.size() != b.size()) {
    printf("NO\n");
    return 0;
  }
  bool ones_a = 0, ones_b = 0;
  for (char c : a) {
    if (c == '1') {
      ones_a = 1;
      break;
    }
  }
  for (char c : b) {
    if (c == '1') {
      ones_b = 1;
      break;
    }
  }
  if (ones_a ^ ones_b)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
