#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  int an1 = 0, bn1 = 0;
  cin >> a >> b;
  if (a.size() != b.size()) {
    cout << "NO";
    return 0;
  }
  for (long long i = 0; i < a.size(); i++)
    if (a[i] == '1') an1++;
  for (long long i = 0; i < b.size(); i++)
    if (b[i] == '1') bn1++;
  if (an1 == 0 && bn1 == 0)
    cout << "YES";
  else if (an1 != 0 && bn1 == 0 || an1 == 0 && bn1 != 0)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
