#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
int main() {
  read_file();
  string s, t;
  while (cin >> s >> t) {
    int n = s.length();
    if (t.length() != n) {
      cout << "NO" << '\n';
      continue;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) cnt += s[i] != t[i];
    if (cnt != 2) {
      cout << "NO" << '\n';
      continue;
    }
    int x, y;
    for (int i = 0; i < n; i++)
      if (s[i] != t[i]) {
        x = i;
        break;
      }
    for (int i = n - 1; i >= 0; i--)
      if (s[i] != t[i]) {
        y = i;
        break;
      }
    swap(s[x], s[y]);
    string ans = s == t ? "YES" : "NO";
    cout << ans << '\n';
  }
}
