#include <bits/stdc++.h>
using namespace std;
int main() {
  long i, a = 0, b, j, b1[26] = {}, b2[26] = {};
  string s1, s2;
  vector<long> v1, v2;
  cin >> s1 >> s2;
  if (s1.size() != s2.size()) {
    cout << "NO";
    return 0;
  }
  for (i = 0; i < s1.size(); i++) {
    if (s1[i] != s2[i]) {
      a++;
      v1.push_back(i);
    }
  }
  if (a != 2) {
    cout << "NO";
    return 0;
  }
  if ((s1[v1[0]] == s2[v1[1]]) && (s2[v1[0]] == s1[v1[1]]))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
