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