#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  c_p_c();
  string str;
  string str1;
  cin >> str >> str1;
  if (str.length() != str1.length()) {
    cout << "NO";
  } else {
    long long n = str.length();
    long long count = 0;
    long long a = -1, b = -1;
    long long i = 0;
    while (i < n) {
      if (str[i] != str1[i]) {
        if (a == -1) {
          a = i;
        } else {
          b = i;
        }
        count++;
      }
      i++;
    }
    if (count == 2) {
      swap(str[a], str[b]);
      if (str == str1)
        cout << "YES";
      else
        cout << "NO";
    } else {
      cout << "NO";
    }
  }
  return 0;
}
