#include <bits/stdc++.h>
using namespace std;
int main() {
  string x, y;
  int diff = 0;
  int change[2];
  cin >> x >> y;
  if (x.length() != y.length()) {
    cout << "NO";
    return 0;
  }
  int l = x.length();
  for (int i = 0; i < l; i++) {
    if (x[i] != y[i]) {
      diff++;
      if (diff == 3) {
        cout << "NO";
        return 0;
      }
      change[diff - 1] = i;
    }
  }
  if (diff == 2 && x[change[0]] == y[change[1]] && x[change[1]] == y[change[0]])
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
