#include <bits/stdc++.h>
using namespace std;
string a, b;
int x, y, p, q;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> a >> b;
  x = 0, y = 0;
  if (a.size() != b.size()) {
    cout << "NO\n";
    return 0;
  }
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == '1') x++;
    if (b[i] == '1') y++;
  }
  if ((!x && !y) || (x && y))
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
