#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[1000005], b[1000005];
  cin >> a >> b;
  int n = strlen(a), m = strlen(b);
  int A = count(a, a + n, '1'), B = count(b, b + m, '1');
  if (n != m)
    puts("NO");
  else if (A == 0 && B == 0)
    puts("YES");
  else if (A && B)
    puts("YES");
  else
    puts("NO");
  return 0;
}
