#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
char s1[N], s2[N];
int main() {
  scanf("%s %s", s1, s2);
  int len1 = strlen(s1);
  int len2 = strlen(s2);
  if (len1 != len2)
    printf("NO\n");
  else {
    bool is1 = false, is2 = false;
    for (int i = 0; i < len1; ++i) {
      if (s1[i] == '1') {
        is1 = true;
        break;
      }
    }
    for (int i = 0; i < len2; ++i) {
      if (s2[i] == '1') {
        is2 = true;
        break;
      }
    }
    if (is1 == is2)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
