#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
int main() {
  read_file();
  string a, b;
  char str[1000000 + 1];
  while (scanf("%s", str) != EOF) {
    a = str;
    scanf("%s", str);
    b = str;
    int n = a.length(), m = b.length();
    if (n != m) {
      printf("NO\n");
      continue;
    }
    if (n == 1) {
      string ans = a == b ? "YES" : "NO";
      printf("%s\n", ans.c_str());
      continue;
    }
    bool aHasOne, bHasOne;
    aHasOne = bHasOne = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] == '1') aHasOne = 1;
      if (b[i] == '1') bHasOne = 1;
    }
    string ans = aHasOne == bHasOne ? "YES" : "NO";
    printf("%s\n", ans.c_str());
  }
}
