#include <bits/stdc++.h>
using namespace std;
void Get(int &T) {
  char C;
  bool F = 0;
  for (; C = getchar(), C < '0' || C > '9';)
    if (C == '-') F = 1;
  for (T = C - '0'; C = getchar(), C >= '0' && C <= '9'; T = T * 10 + C - '0')
    ;
  F && (T = -T);
}
char A[10000005];
char B[10000005];
void Init() { scanf("%s%s", A + 1, B + 1); }
int N, M;
void Err() {
  puts("NO");
  exit(0);
}
int SumA, SumB;
void Work() {
  N = strlen(A + 1);
  M = strlen(B + 1);
  if (N != M) Err();
  for (int i = 1; i <= N; i++) SumA += (A[i] == '1');
  for (int i = 1; i <= N; i++) SumB += (B[i] == '1');
  if (SumA > 1) SumA = 1;
  if (SumB > 1) SumB = 1;
  if (SumA != SumB) Err();
}
void Output() { puts("YES"); }
int main() {
  Init();
  Work();
  Output();
  return 0;
}
