#include <bits/stdc++.h>
using namespace std;
void solve() {
  string a, b;
  cin >> a >> b;
  if (a.length() != b.length()) {
    cout << "NO";
    return;
  }
  pair<char, char> p;
  bool fg = false;
  long long i = 0;
  for (; i < a.length(); i++) {
    if (a[i] == b[i]) continue;
    if (!fg) {
      p = {a[i], b[i]};
      fg = true;
    } else if (p.first == b[i] and p.second == a[i]) {
      i++;
      p = {'#', '#'};
      break;
    } else {
      cout << "NO";
      return;
    }
  }
  if (p.first != '#') {
    cout << "NO";
    return;
  }
  for (; i < a.length(); i++) {
    if (a[i] != b[i]) {
      cout << "NO";
      return;
    }
  }
  cout << "YES";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
