#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
int n, k, t1, t2;
vector<pair<double, int>> v;
int main() {
  string a, b;
  cin >> a >> b;
  int f = -1;
  bool ok = false;
  int cnt = 0;
  if (a.length() != b.length()) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < a.length(); i++) {
    if (a[i] != b[i]) {
      cnt++;
      if (f == -1)
        f = i;
      else {
        if (b[f] == a[i] && a[f] == b[i]) {
          ok = true;
        }
      }
    }
  }
  if (cnt == 0 && !ok) {
    cout << "YES";
  } else if (cnt == 2 && ok) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
