#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, nt, b, i;
  string second, t;
  char a;
  vector<long long int> v;
  cin >> second;
  cin >> t;
  n = second.length();
  nt = t.length();
  if (n != nt) {
    cout << "NO";
    return 0;
  }
  for (i = 0; i < n; i++) {
    if (second[i] != t[i]) {
      v.push_back(i);
    }
  }
  if (v.size() > 2 || v.size() == 1) {
    cout << "NO";
    return 0;
  }
  a = second[v[0]];
  second[v[0]] = second[v[1]];
  second[v[1]] = a;
  for (i = 0; i < n; i++) {
    if (second[i] != t[i]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
