#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> v;
vector<pair<int, int>> v2;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  if (s1.length() != s2.length()) {
    cout << "NO" << endl;
    return 0;
  }
  int n = s1.length();
  bool b1 = 0, b2 = 0;
  for (int i = 0; i < n; i++) {
    if (s1[i] == '1') b1 = 1;
    if (s2[i] == '1') b2 = 1;
  }
  if (b1 == b2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
