#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int MAXN = 2e5 + 5;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string a, b;
  cin >> a >> b;
  vector<long long int> id;
  if (a.length() != b.length()) return cout << "NO", 0;
  for (long long int i = 0; i < a.length(); i++) {
    if (a[i] != b[i]) id.push_back(i);
  }
  if (id.size() == 2 && a[id[0]] == b[id[1]] && a[id[1]] == b[id[0]])
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
