#include <bits/stdc++.h>
using namespace std;
namespace RED {
istream& operator>>(istream& it, pair<long long, long long>& th) {
  it >> th.first >> th.second;
  return it;
}
ostream& operator<<(ostream& it, pair<long long, long long>& th) {
  it << th.first + 1 << " " << th.second + 1;
  return it;
}
}  // namespace RED
namespace RED {
int _C(int n, int k) {
  int c = 1;
  if (2 * k > n) k = n - k;
  for (int i = 0; i < k;) {
    c = (c * n--) / (++i);
  }
  return c;
}
struct Singleton {
  void star() {
    int tests = 1;
    init();
    for (int i = 0; i < tests; ++i) {
      cina();
      if (!solve()) {
        cout << "NO";
        continue;
      }
      couta();
    }
  }
  string s1, s2;
  void init() {}
  void cina() { cin >> s1 >> s2; }
  bool solve() {
    if (s1.size() != s2.size()) return false;
    bool l1 = 0, l2 = 0;
    for (auto& it : s1) {
      if (it == '1') l1 = 1;
    }
    for (auto& it : s2) {
      if (it == '1') l2 = 1;
    }
    if (l1 != l2) return false;
    return true;
  }
  void couta() { cout << "YES"; }
};
}  // namespace RED
int main() {
  int amount_test = 1;
  ios::sync_with_stdio(0);
  cin.tie(0);
  vector<RED::Singleton> v(1);
  for (int i = 0; i < amount_test; ++i) {
    v.clear();
    v.resize(1);
    v[0].star();
  }
}
