#include <bits/stdc++.h>
using namespace std;
string S1, S2;
string solve() {
  vector<pair<char, char> > test;
  int cnt = 0;
  if (S1.size() != S2.size()) return "NO";
  for (int i = 0; i < S1.size(); i++)
    if (S1[i] != S2[i]) {
      cnt++;
      test.push_back(make_pair(S1[i], S2[i]));
      if (cnt > 2) return "NO";
    }
  if (test[0].first == test[1].second && test[0].second == test[1].first)
    return "YES";
  return "NO";
}
int main() {
  cin >> S1 >> S2;
  cout << solve() << endl;
  return 0;
}
