#include <bits/stdc++.h>
using namespace std;
long long INF = 1e9;
const int MAX = 1e5 + 7, N = 1e5 + 3;
double pi = cos(-1);
long long r, l, k, m, n, ans;
int main() {
  string str1, str2;
  cin >> str1 >> str2;
  if (str1.length() != str2.length()) {
    cout << "NO" << endl;
    return 0;
  }
  int c1 = 0, c2 = 0;
  if (str1 == str2) {
    cout << "YES" << endl;
    return 0;
  }
  for (int i = 0; i < str1.length(); i++) {
    if (str1[i] == '1') {
      c1++;
    }
    if (str2[i] == '1') {
      c2++;
    }
  }
  if (c1 == 0 or c2 == 0) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  return 0;
}
