#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
inline bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second == b.second) return a.first < b.first;
  return a.first < b.first;
}
int drx[8] = {-2, -2, -1, -1, 1, 1, 2, 2};
int dcy[8] = {-1, 1, -2, 2, -2, 2, -1, 1};
int dirx[4] = {-1, 0, 1, 0};
int diry[4] = {0, -1, 0, 1};
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd<T>(a, b);
}
template <class T>
inline T power(T b, T p) {
  long long ans = 1;
  while (p--) ans *= b;
  return ans;
}
void __print(long long x) { cout << x; }
void __print(double x) { cout << x; }
void __print(long double x) { cout << x; }
void __print(char x) { cout << '\'' << x << '\''; }
void __print(const char *x) { cout << '\"' << x << '\"'; }
void __print(const string &x) { cout << '\"' << x << '\"'; }
void __print(bool x) { cout << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cout << '{';
  __print(x.first);
  cout << ',';
  __print(x.second);
  cout << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cout << '{';
  for (auto &i : x) cout << (f++ ? "," : ""), __print(i);
  cout << "}";
}
void _print() { cout << "\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cout << ", ";
  _print(v...);
}
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<int> rng(0, 1);
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long extgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long x1, y1;
  long long d = extgcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - y1 * (a / b);
  return d;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
bool isPowerOfTwo(long long n) {
  if (n == 0) return false;
  return (((long long)ceil(log2(n)) == (long long)floor(log2(n))) + 1);
}
long long powm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
long long divide(long long a, long long b) {
  return (a % 1000000007) * powm(b, 1000000007 - 2) % 1000000007;
}
long long mul(long long a, long long b) {
  return ((a % 1000000007) * (b % 1000000007)) % 1000000007;
}
long long add(long long a, long long b) {
  return (a % 1000000007 + b % 1000000007) % 1000000007;
}
long long Totfun(long long n) {
  long long z = n;
  if (n % 2 == 0) {
    while (n % 2 == 0) {
      n /= 2;
    }
    z /= 2;
  }
  for (long long i = 3; i * i <= n; i += 2) {
    if (isPrime(i) && n % i == 0) {
      while (n % i == 0) {
        n /= i;
      }
      z -= z / i;
    }
  }
  if (n > 1) {
    z -= z / n;
  }
  return z;
}
long long fact[1000000];
long long nCr(long long n, long long r) {
  if (r > n || r < 0) return 0;
  long long z = fact[n];
  z = mul(z, powm(fact[n - r], 1000000007 - 2));
  z = mul(z, powm(fact[r], 1000000007 - 2));
  return z;
}
int powerof(int n, int m) {
  int count = 0;
  while (n % m == 0) {
    count++;
    n = n / m;
  }
  return count;
}
long long factorial(long long n) {
  if (n == 0 || n == 1) return 1;
  long long ans = n * factorial(n - 1);
  return ans;
}
vector<long long> primetilln(long long n) {
  vector<long long> v;
  for (long long i = 2; i <= n; i++) {
    if (isPrime(i)) {
      v.push_back(i);
    }
  }
  return v;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(20);
  string s, t;
  cin >> s >> t;
  bool flag1 = true, flag2 = true;
  if (s.size() != t.size())
    cout << "NO" << '\n';
  else if (s == t)
    cout << "YES" << '\n';
  else {
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '1') flag1 = false;
      if (t[i] == '1') flag2 = false;
    }
    if (flag1 || flag2)
      cout << "NO" << '\n';
    else
      cout << "YES" << '\n';
  }
  return 0;
}
