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