#include <bits/stdc++.h>
const long long MXN = 1e6 + 1;
const long long MNN = 1e3 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
using namespace std;
long long n, m, b[222222], mx = -1, mn = INF, a, ans, k, sum, x, q, c[111111],
                           pr[111111];
string second, s1;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  vector<long long> v;
  cin >> second >> s1;
  if (second.size() != s1.size()) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < second.size(); i++) {
    if (second[i] != s1[i]) {
      v.push_back(i);
    }
  }
  if (v.size() != 2) {
    cout << "NO";
    return 0;
  }
  swap(second[v[0]], second[v[1]]);
  if (second == s1) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
