#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  vector<pair<char, char>> mp;
  int la = a.length();
  int lb = b.length();
  if (la != lb)
    cout << "NO";
  else {
    int i;
    for (i = 0; i < la; i++)
      if (a[i] != b[i]) {
        mp.push_back(make_pair(a[i], b[i]));
      }
    if (mp.size() != 2)
      cout << "NO";
    else if (mp[0].first == mp[1].second && mp[1].first == mp[0].second)
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
