#include <bits/stdc++.h>
using namespace std;
void sprint(string s) {
  for (int i = 0; i < s.size(); ++i) printf("%c", s[i]);
  printf("\n");
}
string f(string s) {
  for (int i = 0; i < s.size() - 1; ++i) {
    if (s[i] == '0') continue;
    if (s[i] == '1') s[i] = '0', s[i + 1] = '1';
  }
  return s;
}
int main() {
  ios_base::sync_with_stdio(0);
  string a, b;
  cin >> a >> b;
  string p = f(a);
  string q = f(b);
  if (p == q)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
