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