#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 3e5, M = N;
void solve() {
  long long a, b, n, m;
  long long input;
  string str1, str2;
  cin >> str1 >> str2;
  if (str1 == str2) {
    cout << "YES" << endl;
    return;
  }
  n = str1.length();
  m = str2.length();
  if (n != m) {
    cout << "NO" << endl;
    return;
  }
  bool count1 = true;
  bool count2 = true;
  for (int i = 0; i < n; i++) {
    if (str1[i] == '1') {
      count1 = false;
    }
    if (str2[i] == '1') {
      count2 = false;
    }
  }
  if (count1 == false && count2 == true || count1 == true && count2 == false) {
    cout << "NO" << endl;
  } else
    cout << "YES" << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
