#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int cnt = 0, id[2];
  if (s1.size() != s2.size()) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = 0; i < s1.size(); i++) {
    if (s1[i] != s2[i]) {
      id[cnt] = i;
      cnt++;
    }
    if (cnt > 2) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (cnt == 2 and s1[id[0]] == s2[id[1]] and s1[id[1]] == s2[id[0]])
    cout << "YES" << endl;
  else {
    cout << "NO" << endl;
  }
}
