#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  long int i;
  vector<long int> v;
  for (i = 0; i < min(s1.length(), s2.length()); ++i) {
    if (s1[i] == s2[i])
      continue;
    else
      v.push_back(i);
    if (v.size() > 2) break;
  }
  if ((int)v.size() == 0 && s1.length() == s2.length())
    cout << "YES";
  else {
    if (v.size() == 2) {
      swap(s1[v[0]], s1[v[1]]);
      if (s1 == s2)
        cout << "YES";
      else
        cout << "NO";
    } else
      cout << "NO";
  }
  return 0;
}
