#include <bits/stdc++.h>
using namespace std;
int main() {
  string s[2];
  for (int i = 0; i < 2; i++) {
    string v;
    getline(cin, v);
    s[i] = v;
  }
  if (s[0].size() != s[1].size())
    puts("NO");
  else {
    vector<int> v;
    for (int i = 0; i < (int)s[0].size(); i++) {
      if (s[0][i] != s[1][i]) v.push_back(i);
    }
    if (v.size() == 1 || v.size() > 2)
      puts("NO");
    else if (v.size() == 0)
      puts("YES");
    else if (s[0][v[0]] == s[1][v[1]] && s[1][v[0]] == s[0][v[1]])
      puts("YES");
    else
      puts("NO");
  }
}
