#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long i, k, l, t = 0;
  string b, a, c;
  cin >> a >> b;
  if (a.size() != b.size()) {
    cout << "NO" << endl;
    return 0;
  }
  l = a.size();
  for (i = 0; i < l; i++) {
    if (a[i] != b[i]) {
      c = c + a[i] + b[i];
      t = t + 1;
      if (t > 2) i = l;
    }
  }
  if (c.size() == 4 && c[0] == c[3] && c[1] == c[2]) {
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}
