#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  bool test = true;
  if (s1.length() != s2.length()) test = false;
  int c = 0;
  char c1[2], c2[2];
  for (int i = 0; i < s1.length(); i++) {
    if (s1[i] != s2[i]) {
      c1[c] = s1[i];
      c2[c] = s2[i];
      c++;
      if (c > 2) {
        test = false;
        break;
      }
    }
  }
  if (c1[0] != c2[1] || c1[1] != c2[0]) test = false;
  if (test)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
