#include <bits/stdc++.h>
using namespace std;
void solve() {
  string a, b;
  cin >> a >> b;
  long long c1 = 0, c0 = 0;
  long long as = a.size();
  long long bs = b.size();
  bool ans = 1;
  if (as != bs)
    ans = 0;
  else {
    bool x = 0, y = 0;
    for (auto i : a) {
      if (i == '1') x = 1;
    }
    for (auto i : b) {
      if (i == '1') y = 1;
    }
    if (x == y)
      ans = 1;
    else
      ans = 0;
  }
  if (ans)
    cout << "YES\n";
  else
    cout << "NO\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
