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