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