#include <bits/stdc++.h>
char fist[100100], sec[100100];
using namespace std;
int main() {
  long long int n, l, i, min, ch = 0, nom, j, delf, dels, k, second = 0,
                              first = 0;
  char fi, se, pse, pfi;
  cin >> fist;
  cin >> sec;
  k = strlen(fist);
  l = strlen(sec);
  if (k != l) {
    printf("NO");
    return 0;
  }
  for (i = 0; i < k; i++) {
    if (fist[i] != sec[i] && ch == 1) {
      pse = se;
      pfi = fi;
    }
    if (fist[i] != sec[i]) {
      ch++;
      fi = fist[i];
      se = sec[i];
    }
  }
  if (ch == 2 && fi == pse && se == pfi) {
    printf("YES");
    return 0;
  }
  printf("NO");
  return 0;
}
