#include <bits/stdc++.h>
using namespace std;
long long inf = 1e18 + 42;
const int M = 1e9 + 7;
const int MN = 1e9;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  string s1, s2;
  cin >> s1 >> s2;
  if (s1.size() != s2.size()) return cout << "NO" << endl, 0;
  int cnt = 0;
  string ss1, ss2;
  for (int i = 0; i < s1.size(); ++i) {
    if (s1[i] != s2[i]) {
      cnt++;
      ss1 += s1[i];
      ss2 += s2[i];
    }
  }
  if (cnt == 2 && ss1[0] == ss2[1] && ss1[1] == ss2[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
