#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[1000001], b[1000001];
  cin >> a >> b;
  if (strcmp(a, b) == 0 || (strlen(a) == strlen(b) && strchr(a, '1') != NULL &&
                            strchr(b, '1') != NULL)) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
