#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c;
  pair<int, int> p;
  int count = 0;
  cin >> a >> b;
  if (a == b) {
    cout << "YES" << endl;
    return 0;
  }
  for (int i = 0; i < a.length(); i++) {
    if (a[i] != b[i]) {
      c.push_back(b[i]);
      if (count == 0) {
        p.first = i;
      }
      if (count == 1) {
        p.second = i;
      }
      count++;
    }
  }
  int index1 = a.find(c[0]);
  int index2 = a.find(c[1]);
  if (index1 != string::npos && index2 != string::npos) {
    a[p.first] = c[0];
    a[p.second] = c[1];
  }
  if (a == b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
