#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  long la = a.length(), lb = b.length(), x = 0, y = 0, d = 0;
  if (la != lb) {
    cout << "NO";
    return 0;
  }
  for (long i = 0; i < la; i++) {
    if (a[i] != b[i]) {
      d++;
      if (x == 0)
        x = i;
      else if (y == 0)
        y = i;
    }
  }
  if (d != 2 && cout << "NO") return 0;
  swap(a[x], a[y]);
  if (a == b) {
    cout << "YES";
    return 0;
  } else {
    cout << "NO";
    return 0;
  }
  return 0;
}
