#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000010;
char a[MAXN];
char b[MAXN];
int one = 0;
int main() {
  cin.getline(a, MAXN);
  cin.getline(b, MAXN);
  int len = strlen(a);
  int len2 = strlen(b);
  if (len != len2) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = 0; i < len; i++)
    if (a[i] == '1') one++;
  for (int i = 0; i < len; i++) {
    if (b[i] != a[i]) {
      if (a[i] == '0')
        if (one > 0)
          one++;
        else {
          cout << "NO" << endl;
          return 0;
        }
      if (a[i] == '1')
        if (one > 1)
          one--;
        else {
          cout << "NO" << endl;
          return 0;
        }
    }
  }
  cout << "YES" << endl;
  return 0;
}
