#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 3e5 + 10;
const long long MAX = 1e18, OO = 1e16;
int n, a[N];
long long in[N], out[N], power[N];
int color[N];
int cnt = 0, have = 0;
stack<int> st;
void getcount(int u) {
  while (!st.empty()) {
    ++cnt;
    if (u == st.top()) return;
    st.pop();
  }
}
void clear() {
  while (!st.empty()) st.pop();
}
bool cyc(int u) {
  color[u] = 1;
  st.push(u);
  bool ret = 0;
  if (!color[a[u]])
    ret |= cyc(a[u]);
  else if (color[a[u]] == 1) {
    getcount(a[u]);
    return true;
  }
  color[u] = 2;
  return ret;
}
int main() {
  string a, b;
  cin >> a >> b;
  if (a.size() != b.size()) return cout << "NO" << endl, 0;
  if (a == b) return cout << "YES" << endl, 0;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < a.size(); ++i) {
    if (a[i] == '1') ++cnt1;
    if (b[i] == '1') ++cnt2;
  }
  if (cnt1 && cnt2) return cout << "YES" << endl, 0;
  return cout << "NO" << endl, 0;
}
