#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  if (a.size() != b.size()) {
    puts("NO");
    return 0;
  }
  if (a == b) {
    puts("YES");
    return 0;
  }
  bool a1, b1;
  a1 = b1 = false;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == '1') a1 = true;
    if (b[i] == '1') b1 = true;
  }
  if (a1 && b1)
    puts("YES");
  else
    puts("NO");
}
