#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1000010;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  string s, t;
  cin >> s >> t;
  int n = s.length();
  int m = t.length();
  int flag1 = -1;
  int flag2 = -1;
  if (n != m) {
    cout << "NO" << '\n';
    return 0;
  }
  if (s == t) {
    cout << "YES" << '\n';
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    if (s[i] == '1') {
      flag1 = 1;
    }
    if (t[i] == '1') {
      flag2 = 1;
    }
  }
  if (flag1 == -1 || flag2 == -1) {
    cout << "NO" << '\n';
    return 0;
  }
  cout << "YES" << '\n';
  return 0;
}
