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