#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  if (a.length() != b.length()) {
    cout << "NO" << endl;
    return 0;
  } else {
    int fza = 0, fzb = 0, foa = 0, fob = 0;
    int len = (int)b.length();
    for (int i = 0; i < len; i++) {
      if (a[i] == '0') fza = 1;
      if (a[i] == '1') foa = 1;
      if (b[i] == '0') fzb = 1;
      if (b[i] == '1') fob = 1;
    }
    if ((foa == 0 && fob == 1) || (foa == 1 && fob == 0))
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
