#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  int c1, c2;
  bool yes = true;
  if (a.size() != b.size()) {
    puts("NO");
    return 0;
  }
  for (int i = 0, _n = (a.size()); i < _n; i++) {
    c1 += a[i] == '1';
    c2 += b[i] == '1';
  }
  if (c1 && c2 || (!c1 && !c2))
    puts("YES");
  else
    puts("NO");
  return 0;
}
