#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  int swap = 0, a[1000];
  cin >> s >> t;
  if (s.length() != t.length()) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != t[i]) {
      if (swap >= 2) {
        cout << "NO";
        return 0;
      } else {
        a[swap] = i;
        swap++;
      }
    }
  }
  if (t[a[0]] == s[a[1]] && s[a[0]] == t[a[1]])
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
