#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[1000010], b[1000010];
  while (scanf("%s%s", &a, &b) != EOF) {
    int len1 = strlen(a);
    int len2 = strlen(b);
    int ans = 0;
    if (len1 != len2) {
      ans = 1;
    } else {
      if (len1 == 1) {
        if (a[0] != b[0])
          ans = 1;
        else
          ans = 0;
      } else {
        if (strcmp(a, b) == 0)
          ans = 0;
        else {
          int j1 = 0, j2 = 0;
          for (int i = 0; i < len1; i++)
            if (a[i] == '1') j1 = 1;
          for (int i = 0; i < len1; i++)
            if (b[i] == '1') j2 = 1;
          if (j1 && j2)
            ans = 0;
          else
            ans = 1;
        }
      }
    }
    if (!ans)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
