#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  char c[3], d[3];
  cin >> a >> b;
  int e = 0, l = 0;
  int len1 = a.size();
  int len2 = b.size();
  if (len1 != len2)
    cout << "NO" << endl;
  else {
    for (int i = 0; i < len1; i++) {
      if (a[i] != b[i]) {
        c[e++] = a[i];
        d[l++] = b[i];
      }
      if (e > 2) {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (e == 0 || e == 2) {
      if (c[0] == d[1] && c[1] == d[0]) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    } else {
      cout << "NO" << endl;
    }
  }
}
