#include <bits/stdc++.h>
using namespace std;
struct unit {
  long long int a[1000000];
};
long long fact(long long int x) {
  if (x == 1 || x == 0)
    return 1;
  else
    return x * fact(x - 1);
}
long long power(long long int x, long long int n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return power(x * x, n / 2);
  else
    return x * power(x * x, (n - 1) / 2);
}
bool cmp(const pair<long long int, long long int>& a,
         const pair<long long int, long long int>& b) {
  if (a.second <= b.second) {
    if (a.second == b.second)
      return a.first < b.first;
    else
      return a.second < b.second;
  } else
    return a.second < b.second;
}
int main() {
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
  long long i, j, k, l, m, n, strequal1 = 0, strequal2 = 0;
  string s1, s2;
  cin >> s1 >> s2;
  if ((long long int)s1.size() != (long long int)s2.size())
    cout << "NO"
         << "\n";
  else {
    for (i = 0; i < (long long int)s1.size(); i++) {
      if (s1[i] == '1') strequal1 = 1;
      if (s2[i] == '1') strequal2 = 1;
      if (strequal1 == 1 && strequal2 == 1) break;
    }
    if ((strequal1 == 1 && strequal2 == 1) ||
        (strequal1 == 0 && strequal2 == 0))
      cout << "YES";
    else
      cout << "NO";
  }
}
