#include <bits/stdc++.h>
using namespace std;
char s1[1000010], s2[1000010];
int main() {
  cin >> s1 >> s2;
  long n, m;
  int k1, k2;
  n = strlen(s1);
  m = strlen(s2);
  if (n != m)
    cout << "NO";
  else {
    int i;
    k1 = k2 = 0;
    for (i = 0; i < n; i++) {
      if (s1[i] == '1') {
        k1 = 1;
        break;
      }
    }
    for (i = 0; i < m; i++) {
      if (s2[i] == '1') {
        k2 = 1;
        break;
      }
    }
    if (k1 == k2)
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
