#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, f = 0;
  string s1, s2;
  cin >> s1 >> s2;
  pair<int, int> p1;
  pair<int, int> p2;
  if (s1.length() != s2.length())
    cout << "NO";
  else {
    for (i = 0; i < s1.length(); i++) {
      if (s1.at(i) == '0')
        p1.first++;
      else
        p1.second++;
      if (s2.at(i) == '0')
        p2.first++;
      else
        p2.second++;
    }
    if (p1.second >= 1 && p2.second == 0) f = 1;
    if (p1.second == 0 && p2.second > 0) f = 1;
    if (f == 1)
      cout << "NO";
    else
      cout << "YES";
  }
}
