#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a;
  cin >> b;
  int lena = a.length(), lenb = b.length();
  if (lena != lenb)
    cout << "NO";
  else {
    int count = 0;
    char old1, old2;
    for (int i = 0; i < lena && count < 3; i++) {
      if (a[i] != b[i]) {
        count++;
        if (count == 1) {
          old1 = b[i];
          old2 = a[i];
        }
        if (count == 2 && (a[i] != old1 || b[i] != old2)) count = 3;
      }
    }
    if (count == 2)
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
