#include <bits/stdc++.h>
using namespace std;
void seif() { std::ios_base::sync_with_stdio(0); }
int fmp[30], smp[30];
int main() {
  seif();
  string s1, s2;
  cin >> s1 >> s2;
  if (s1.length() != s2.length()) return cout << "NO", 0;
  for (int i = 0; i < s1.length(); i++) {
    fmp[s1[i] - 'a']++;
    smp[s2[i] - 'a']++;
  }
  for (int i = 0; i < 30; i++) {
    if (fmp[i] != smp[i]) return cout << "NO", 0;
  }
  int ans = 0;
  for (int i = 0; i < s1.length(); i++) {
    if (s1[i] != s2[i]) ans++;
  }
  if (ans == 2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
