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