#include <bits/stdc++.h>
const double Pi = acos(-1.0);
using namespace std;
string s, t;
int main(int argc, char** argv) {
  cin >> s >> t;
  int slen = s.length(), tlen = t.length();
  if (slen != tlen) {
    printf("NO\n");
    return 0;
  }
  vector<int> diff;
  for (int i = 0; i < slen; i++) {
    if (s[i] != t[i]) {
      diff.push_back(i);
    }
  }
  int siz = diff.size();
  if (siz != 2 && siz != 0) {
    printf("NO\n");
    return 0;
  }
  if (siz == 0) {
    printf("YES\n");
    return 0;
  }
  int i = diff[0], j = diff[1];
  if (s[i] == t[j] && s[j] == t[i]) {
    printf("YES\n");
    return 0;
  }
  printf("NO\n");
  return 0;
}
