#include <bits/stdc++.h>
using namespace std;
int const N = 2e5 + 5, M = 1e9, OO = 0x3f3f3f3f, MOD = 1e9 + 7;
string a, b;
int n, m;
bool f1, f2;
int main() {
  cin >> a >> b;
  n = a.size();
  m = b.size();
  if (n == m) {
    if (a == b)
      puts("YES");
    else {
      for (int i = 0; i < n && !f1; i++)
        if (a[i] - '0') f1 = 1;
      for (int i = 0; i < n && !f2; i++)
        if (b[i] - '0') f2 = 1;
      if (f1 && f2)
        puts("YES");
      else
        puts("NO");
    }
  } else
    puts("NO");
  return 0;
}
