#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  int i, c = 0;
  cin >> a >> b;
  for (i = 0; i < a.size() && i < b.size(); i++) {
    if (a[i] != b[i]) {
      c++;
    }
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a == b && c == 2) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}
