#include <bits/stdc++.h>
using namespace std;
bool isnot(long long x) {
  if (x >= 1 && x <= 9) return false;
  return true;
}
int32_t main() {
  long long x, y, d = 0;
  string s1, s2;
  cin >> s1 >> s2;
  if (s1.size() != s2.size()) {
    cout << "NO" << endl;
    return 0;
  }
  for (long long i = 0; i < min(s1.size(), s2.size()); i++) {
    if (s1[i] != s2[i] && d == 0) {
      d++;
      x = i;
    } else if (s1[i] != s2[i]) {
      y = i;
      d++;
    }
  }
  if (d != 2)
    cout << "NO" << endl;
  else if (s1[x] == s2[y] && s2[x] == s1[y])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
