#include <bits/stdc++.h>
using namespace std;
int G[101][101], b[101], vis[101], a[100001];
vector<int> Ai;
vector<string> As;
vector<char> Ac;
bool onoroff[100001];
int N, M, cnt, ind, sum, maxx, minn, mx = 999999999, mn, x, y;
string S, A, B;
char ch;
struct TAZ {
  int X, Y;
};
TAZ used[101];
int main() {
  getline(cin, A);
  getline(cin, B);
  for (int i = 0; i < A.size(); i++) {
    if (A[i] != B[i]) {
      cnt++;
    }
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  if (A == B && cnt == 2) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
