#include <bits/stdc++.h>
char a[1000006], b[1000006];
int main() {
  while (scanf("%s", a) != EOF) {
    scanf("%s", b);
    int len1 = strlen(a), len2 = strlen(b);
    if (len1 != len2) {
      printf("NO\n");
      continue;
    }
    int num1 = 0, num2 = 0;
    for (int i = 0; i < len1; i++) {
      if (a[i] == '1') num1++;
      if (b[i] == '1') num2++;
    }
    if ((num2 == 0 && num1 == 0) || (num2 != 0 && num1 != 0)) {
      printf("YES\n");
    } else
      printf("NO\n");
  }
  return 0;
}
