#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  if (s1.size() != s2.size())
    cout << "NO";
  else {
    vector<int> x;
    for (int i = 0; i < s1.size(); i++) {
      if (s1[i] != s2[i]) x.push_back(i);
    }
    if (x.size() == 2) {
      swap(s1[x[0]], s1[x[1]]);
    }
    if (s1.find(s2) != string::npos)
      cout << "YES";
    else
      cout << "NO";
  }
}
