#include <bits/stdc++.h>
using namespace std;
int main() {
  string ss, tt, p, f;
  int cnt = 0, flag = -1, temp = -1;
  cin >> ss >> tt;
  if (ss.size() != tt.size()) return cout << "NO", 0;
  for (size_t i = 0; i < ss.size(); i++) {
    if (ss[i] != tt[i]) {
      cnt++;
      if (cnt > 2) return cout << "NO", 0;
      if (flag == -1) {
        flag = i;
      } else {
        temp = i;
        swap(ss[flag], ss[temp]);
        p = ss.substr(0, temp);
        f = tt.substr(0, temp);
        if (p != f)
          return cout << "NO", 0;
        else
          flag = -1;
      }
    }
  }
  if (ss == tt)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
}
