#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  int x, y;
  int cnt = 0;
  if (a.size() != b.size())
    cout << "NO";
  else {
    for (int i = 0; i < a.size(); i++) {
      if (a[i] != b[i]) {
        if (cnt == 0) {
          x = i;
        } else if (cnt == 1) {
          y = i;
        }
        cnt++;
      }
    }
    if (cnt == 1 || cnt > 2) {
      cout << "NO";
    } else {
      char temp = a[x];
      a[x] = a[y];
      a[y] = temp;
      if (a == b) {
        cout << "YES";
      } else {
        cout << "NO";
      }
    }
  }
  return 0;
}
