#include <bits/stdc++.h>
using namespace std;
int main() {
  string first, second;
  int count = 0;
  int fpos, spos;
  cin >> first;
  cin >> second;
  if (first.length() > second.length() || first.length() < second.length()) {
    cout << "NO";
    return 0;
  }
  fpos = spos = -1;
  for (int i = 0; i < first.length() && count <= 2; ++i) {
    if (first[i] != second[i]) {
      if (fpos == -1)
        fpos = i;
      else
        spos = i;
      ++count;
    }
  }
  if (count == 2 && first[fpos] == second[spos] && second[fpos] == first[spos])
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
