#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
char a[MAXN], b[MAXN];
int main() {
  int i, j, n, sum1, sum2;
  gets(a);
  gets(b);
  sum1 = sum2 = 0;
  int len = strlen(a);
  if (strlen(a) != strlen(b))
    printf("NO\n");
  else {
    for (i = 0; i < len; i++) {
      if (a[i] == '1') sum1++;
      if (b[i] == '1') sum2++;
    }
    if ((sum1 > 0 && sum2 > 0) || sum1 == 0 && sum2 == 0)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
