#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, r;
  cin >> s >> r;
  string o = s, p = r;
  sort(s.begin(), s.end());
  sort(r.begin(), r.end());
  if (r == s) {
    int count = 0;
    int l = s.size();
    for (int i = 0; i < l; i++) {
      if (count > 2) {
        cout << "NO";
        break;
      }
      if (p[i] != o[i]) count++;
    }
    if (count <= 2) cout << "YES";
  } else
    cout << "NO";
}
