#include <bits/stdc++.h>
using namespace std;
bool compare(const pair<int, int>& i, const pair<int, int>& j) {
  return i.first < j.first;
}
int main() {
  string r, s;
  cin >> r >> s;
  vector<int> v;
  if (r.length() != s.length()) {
    cout << "NO"
         << "\n";
    return 0;
  }
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != r[i]) {
      v.push_back(i);
    }
  }
  if (v.size() != 2)
    cout << "NO"
         << "\n";
  else {
    if (s[v[0]] == r[v[1]] && s[v[1]] == r[v[0]])
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
