#include <bits/stdc++.h>
using namespace std;
int prime[1000];
int main() {
  string str1, str2;
  cin >> str1 >> str2;
  int l1 = str1.length(), l2 = str2.length();
  if (l1 != l2)
    cout << "NO" << endl;
  else if (str1 == str2)
    cout << "YES" << endl;
  else {
    int count1 = 0, count2 = 0;
    int c1 = 0, c2 = 0;
    for (int i = 0; i < l1; i++) {
      if (str1[i] == '1')
        count1++;
      else
        count2++;
    }
    for (int i = 0; i < l2; i++) {
      if (str2[i] == '1')
        c1++;
      else
        c2++;
    }
    if (c1 == 0)
      cout << "NO" << endl;
    else if (count1 == 0)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
}
