#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  string p;
  string test1;
  string test2;
  cin >> s >> p;
  int l = s.length();
  int l2 = p.length();
  if (l != l2) {
    cout << "NO";
    return 0;
  }
  int flag = 0;
  for (int i = 0; i < l; i++) {
    if (s[i] == p[i]) {
    } else if (s[i] != p[i] && flag < 2) {
      flag++;
      test1.push_back(s[i]);
      test2.push_back(p[i]);
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (test1[0] == test2[1] && test2[0] == test1[1])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
