#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  string a, b;
  cin >> a >> b;
  if (a.length() != b.length()) {
    cout << "NO";
  } else {
    int ct = 0;
    for (int i = 0; i < a.length(); i++) {
      if (a[i] != b[i]) ct++;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (a == b && ct == 2)
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
