#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const double pi = std::acos(-1);
using namespace std;
const long long int mod = 1000000000 + 7;
long long int power(long long int x, long long int y, long long int md) {
  long long int res = 1;
  x = x % md;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % md;
    y = y >> 1;
    x = (x * x) % md;
  }
  return res;
}
long long int m_mul(long long int a, long long int b) {
  a = a % mod;
  b = b % mod;
  return (a * b + mod) % mod;
}
long long int m_add(long long int a, long long int b) {
  a = a % mod;
  b = b % mod;
  return (a + b + mod) % mod;
}
long long int spf[(long long int)1e7 + 2] = {0};
void siv() {
  spf[1] = 1;
  for (long long int i = 1; i < 1e7 + 2; i++) spf[i] = i;
  for (long long int i = 2; i < 1e7 + 2; i++) spf[i] = 2, i++;
  for (long long int i = 3; i * i < (long long int)1e7 + 2; i++) {
    if (spf[i] == i)
      for (long long int j = i * i; j < (long long int)1e7 + 2; j = j + i)
        if (spf[j] == j) spf[j] = i;
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  long long int tc = 1;
  while (tc--) {
    string s1, s2;
    cin >> s1 >> s2;
    long long int k11 = 0, k21 = 0;
    for (long long int i = 0; i < s1.size(); i++) {
      if (s1[i] == '1') k11++;
    }
    for (long long int i = 0; i < s2.size(); i++) {
      if (s2[i] == '1') k21++;
    }
    if (s1.size() != s2.size())
      cout << "NO" << '\n';
    else if (k11 == 0 && k21 == 0)
      cout << "YES" << '\n';
    else if (k11 == 0 || k21 == 0)
      cout << "NO" << '\n';
    else
      cout << "YES" << '\n';
  }
  return 0;
}
