#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s1, s2;
  cin >> s1 >> s2;
  if (s1.length() != s2.length()) {
    cout << "NO";
    return;
  }
  long long f1 = 0, f2 = 0;
  for (long long i = 0; i < s1.length(); i++) {
    if (s1[i] == '1') f1 = 1;
  }
  for (long long i = 0; i < s1.length(); i++) {
    if (s2[i] == '1') f2 = 1;
  }
  if (f1 != f2)
    cout << "NO";
  else
    cout << "YES";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  cout << "\n";
  return 0;
}
