#include <bits/stdc++.h>
using namespace std;
char str1[1110000], str2[1110000];
int main() {
  int cnt = 0, len, i, j, c = 0;
  cin >> str1 >> str2;
  int l = strlen(str1), l2 = strlen(str2);
  for (i = 0; i < l; i++) {
    if (str1[i] == '0') cnt++;
  }
  for (i = 0; i < l2; i++) {
    if (str2[i] == '0') c++;
  }
  if (l != l2 || (cnt == l && c != l2) || (c == l2 && cnt != l))
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
