#include <bits/stdc++.h>
using namespace std;
char a[1000005], b[1000005];
int i;
int main() {
  cin >> a >> b;
  int l1 = strlen(a);
  int l2 = strlen(b);
  if (l1 != l2) {
    cout << "NO\n";
    return 0;
  }
  int c1 = 0, c2 = 0;
  for (i = 0; i < l1; i++) {
    c1 += a[i] - '0';
    c2 += b[i] - '0';
  }
  if ((c1 == 0 && c2 != 0) || (c1 != 0 && c2 == 0)) {
    cout << "NO\n";
    return 0;
  } else {
    cout << "YES\n";
    return 0;
  }
  return 0;
}
