#include <bits/stdc++.h>
using namespace std;
vector<int> g[101010];
int used[101010];
void dfs(int v) {
  used[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (used[to] == 0) {
      dfs(to);
    }
  }
}
set<int> st;
map<string, int> mpstr;
long long a[101010];
char q, ch[101010];
long long l, r, pref[101010];
long long ans, cnt, sum, max1, min1, ali;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cnt = 0;
  string s1, s2;
  cin >> s1 >> s2;
  vector<int> v;
  if (s1.size() != s2.size()) {
    cout << "NO";
    return 0;
  }
  for (long long i = 0; i < s1.size(); i++) {
    if (s1[i] != s2[i]) v.push_back(i);
  }
  if (v.size() != 2) {
    cout << "NO";
    return 0;
  }
  swap(s1[v[0]], s1[v[1]]);
  if (s1 != s2) {
    cout << "NO";
    return 0;
  }
  cout << "YES";
}
