#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s1, s2;
  cin >> s1 >> s2;
  int freq_s1[26] = {0}, freq_s2[26] = {0};
  for (int i = 0; i < s1.size() || i < s2.size(); ++i) {
    if (i < s1.size()) freq_s1[(int)s1[i] - 97]++;
    if (i < s2.size()) freq_s2[(int)s2[i] - 97]++;
  }
  int temp = 0, s = 0;
  for (int i = 0; i < 26; ++i) {
    if (freq_s2[i] != freq_s1[i]) {
      cout << "NO";
      return 0;
    }
  }
  for (int i = 0; i < s1.size(); ++i) {
    if (s1[i] != s2[i]) temp++;
  }
  if (temp == 2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
