#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:2000000")
#pragma comment(linker, "/HEAP:2000000")
using namespace std;
long long gcd(long long a, long long b) {
  long long c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string a, b;
  cin >> a >> b;
  bool flagA(0), flagB(0);
  string ans = "YES";
  if (a.size() != b.size()) {
    ans = "NO";
  } else {
    for (int i = 0; i < a.size(); i++) {
      if (a[i] == '1') {
        flagA = 1;
      }
      if (b[i] == '1') {
        flagB = 1;
      }
      if (flagA && flagB) {
        break;
      }
    }
    if ((flagA && !flagB) || (!flagA && flagB)) {
      ans = "NO";
    }
  }
  cout << ans << endl;
  return 0;
}
