#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, i, j, count = 0, flag = 0, in, in1;
  string s, s1;
  cin >> s >> s1;
  i = 0;
  if (s.size() == s1.size()) {
    while (s[i]) {
      if (s[i] != s1[i]) {
        count++;
        flag = 1;
        if (count == 1) in = i;
        if (count == 2) in1 = i;
      }
      if (count > 2) {
        flag = 0;
        break;
      }
      i++;
    }
    if (count == 2) {
      if (s[in] != s1[in1] || s[in1] != s1[in]) flag = 0;
    }
    if (flag == 1 && count == 2)
      cout << "YES";
    else
      cout << "NO";
  } else
    cout << "NO";
  return 0;
}
