#include <bits/stdc++.h>
using namespace std;
char s1[1010000];
char s2[1010000];
int main() {
  scanf("%s", s1);
  scanf("%s", s2);
  int len1, len2, i;
  len1 = strlen(s1);
  len2 = strlen(s2);
  int ans;
  if (len1 - len2)
    ans = 0;
  else if (len1 == 1) {
    if (s1[0] == s2[0])
      ans = 1;
    else
      ans = 0;
  } else {
    if (strcmp(s1, s2) == 0)
      ans = 1;
    else {
      int j1, j2;
      j1 = j2 = 0;
      for (i = 0; s1[i]; ++i)
        if (s1[i] == '1') j1 = 1;
      for (i = 0; s2[i]; ++i)
        if (s2[i] == '1') j2 = 1;
      if (j1 && j2)
        ans = 1;
      else
        ans = 0;
    }
  }
  if (ans)
    puts("YES");
  else
    puts("NO");
}
