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