#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, bugi = 0, chigi = 0;
  string s1, s2, a, b;
  cin >> s1 >> s2;
  if (s1.size() == s2.size()) {
    for (i = 0; i < s1.size(); i++) {
      if (s1[i] != s2[i]) {
        bugi++;
        a[chigi] = s1[i];
        b[chigi] = s2[i];
        chigi++;
      }
      if (bugi > 2) break;
    }
    if (bugi == 2) {
      if (a[0] == b[1] && a[1] == b[0])
        puts("YES");
      else
        puts("NO");
    } else
      puts("NO");
  } else
    puts("NO");
  return 0;
}
