#include <bits/stdc++.h>
using namespace std;
int flag[500];
void solve() {
  string x, y;
  cin >> x >> y;
  if (x.size() != y.size()) {
    cout << "NO" << '\n';
    return;
  }
  int cnt = 0;
  int xl = 0;
  int cl = 0;
  int mxx = 0;
  for (int i = 0; i < x.size(); ++i) {
    if (x[i] != y[i]) {
      ++cnt;
      if (cnt == 1) xl = i;
      if (cnt == 2) cl = i;
    }
    flag[x[i]]++;
    mxx = max(mxx, flag[x[i]]);
  }
  if (cnt == 2) {
    if (x[xl] == y[cl] and x[cl] == y[xl]) {
      cout << "YES" << '\n';
      return;
    } else {
      cout << "NO" << '\n';
      return;
    }
  }
  if (cnt == 0) {
    if (mxx > 1) {
      cout << "YES" << '\n';
      return;
    } else {
      cout << "NO" << '\n';
      return;
    }
  }
  {
    cout << "NO" << '\n';
    return;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  for (int i = 1; i <= t; ++i) {
    solve();
  }
  return 0;
}
