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