#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[1000005], b[1000005];
  gets(a);
  gets(b);
  int l = strlen(a), k = strlen(b);
  bool aa = 1, bb = 1;
  for (int i = 0; i < l && aa; i++)
    if (a[i] == '1') aa = 0;
  for (int i = 0; i < k && bb; i++)
    if (b[i] == '1') bb = 0;
  if (aa && !bb || bb && !aa || l != k)
    puts("NO");
  else
    puts("YES");
}
