#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, s2;
  cin >> s >> s2;
  int i, l;
  int a = 0, b = 0;
  l = max(s.size(), s2.size());
  for (i = 0; i < l; i++) {
    if (s[i] != s2[i]) {
      b = a;
      a = i;
    }
  }
  swap(s[a], s[b]);
  if (s == s2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
