#include <bits/stdc++.h>
using namespace std;
char a[1000007], b[1000007];
bool judge() {
  int l1 = strlen(a), l2 = strlen(b);
  if (l1 != l2)
    return false;
  else {
    int sum1 = 0, sum2 = 0;
    for (int i = 0; a[i] != '\0'; i++) {
      if (a[i] == '1') sum1++;
      if (b[i] == '1') sum2++;
    }
    if ((!sum1 && sum2) || (sum1 && !sum2))
      return false;
    else
      return true;
  }
}
int main() {
  scanf("%s%s", a, b);
  if (judge())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
