#include <bits/stdc++.h>
using namespace std;
string s1, s2;
int main() {
  cin >> s1 >> s2;
  if (s1.length() != s2.length())
    cout << "NO";
  else {
    int x = 0;
    int y = 0;
    for (int i = 0; i < s1.length(); i++) {
      if (s1[i] - '0' == 1) x++;
      if (s2[i] - '0' == 1) y++;
    }
    if (x == 0 && y == 0)
      cout << "YES";
    else if (x == 0 && y != 0)
      cout << "NO";
    else if (x != 0 && y == 0)
      cout << "NO";
    else if (x != 0 && y != 0)
      cout << "YES";
  }
  return 0;
}
