#include <bits/stdc++.h>
using namespace std;
bool check(string& a, string& b) {
  if (a.size() != b.size()) return false;
  int ind1 = -1, ind2 = -1;
  bool check = false;
  bool buck[26] = {0};
  int count = 0;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] != b[i]) {
      count++;
      if (count > 2) return false;
      if (ind1 == -1)
        ind1 = i;
      else
        ind2 = i;
    } else {
      if (buck[a[i] - 'a'])
        check = true;
      else
        buck[a[i] - 'a'] = true;
    }
  }
  if (count == 1) return false;
  if (count == 0) {
    return check;
  }
  return (a[ind1] == b[ind2]) && (a[ind2] == b[ind1]);
}
int main() {
  string a, b;
  cin >> a;
  cin >> b;
  if (check(a, b))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
