#include <bits/stdc++.h>
using namespace std;
void __print(long long x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
long long Power(long long a, long long n, long long mod) {
  long long res = 1;
  while (n) {
    if (n % 2 != 0) {
      res = ((res % mod) * (a % mod)) % mod;
      n--;
    } else {
      a = ((a % mod) * (a % mod)) % mod;
      n /= 2;
    }
  }
  return res;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long getSum(long long n) {
  long long sum = 0;
  while (n != 0) {
    sum = sum + n % 10;
    n = n / 10;
  }
  return sum;
}
long long myceil(long long n, long long x) {
  long long y;
  if (n % x == 0) {
    y = n / x;
    return y;
  } else {
    y = n / x + 1;
    return y;
  }
}
long long md = 1000000007;
vector<long long> fact, inv;
void inverse(long long n) {
  if (n >= inv.size()) {
    long long size = inv.size();
    size = size == 0 ? 1 : size;
    inv.resize(n + 1);
    inv[0] = 1;
    for (long long i = size; i <= n; i++) inv[i] = Power(fact[i], md - 2, md);
  }
}
void factorial(long long n) {
  if (n >= fact.size()) {
    long long size = fact.size();
    size = size == 0 ? 1 : size;
    fact.resize(n + 1);
    fact[0] = 1;
    for (long long i = size; i <= n; i++) fact[i] = (fact[i - 1] * i) % md;
  }
}
long long ncr(long long n, long long r) {
  return (((fact[n] * inv[r]) % md) * inv[n - r]) % md;
}
long long primes[1300000];
void Sieve() {
  bool IsPrime[1300000];
  memset(IsPrime, true, sizeof(IsPrime));
  for (long long p = 2; p * p < 1300000; p++) {
    if (IsPrime[p] == true) {
      for (long long i = p * p; i < 1300000; i += p) IsPrime[i] = false;
    }
  }
  long long index = 0;
  for (long long p = 2; p < 1300000; p++)
    if (IsPrime[p]) {
      primes[index] = p;
      index++;
    }
}
void q1();
void q2();
void q3();
void q4();
void q5();
void q6();
void q7();
void q8();
void q9();
void q10();
int32_t main() {
  q5();
  return 0;
}
void q1() {
  long long n, k;
  cin >> n >> k;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long ans = arr[k - 1];
  bool set = true;
  long long cnt = 0;
  for (long long i = k - 2; i >= 0; i--) {
    if (arr[i] != ans) {
      break;
    }
    cnt++;
  }
  for (long long i = k; i < n; i++) {
    if (arr[i] != ans) {
      set = false;
      break;
    }
  }
  if (set) {
    cout << k - 1 - cnt << "\n";
  } else {
    cout << -1 << "\n";
  }
}
void q2() {
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  map<long long, long long> count;
  for (long long i = 0; i < n; i++) count[arr[i]]++;
  bool x1 = true;
  if (count[6] < count[3]) {
    x1 = false;
  }
  if (count[2] == 0) {
    if (count[3] != count[6]) {
      x1 = false;
    }
  }
  if (x1 && count[7] == 0 && count[5] == 0 && count[2] + count[3] == count[1] &&
      count[4] + count[6] == count[1]) {
    if (count[3] != 0) {
      for (long long i = 1; i <= count[3]; i++) {
        cout << 1 << " " << 3 << " " << 6 << "\n";
        count[6]--;
      }
    }
    for (long long i = 1; i <= count[6]; i++) {
      cout << 1 << " " << 2 << " " << 6 << "\n";
    }
    for (long long i = 1; i <= count[4]; i++) {
      cout << 1 << " " << 2 << " " << 4 << "\n";
    }
  } else {
    cout << -1 << "\n";
  }
}
void q3() {
  string s1, s2;
  getline(cin, s1);
  getline(cin, s2);
  map<char, long long> mp1;
  for (long long i = 0; i < s1.length(); i++) {
    mp1[s1[i]]++;
  }
  map<char, long long> mp2;
  for (long long i = 0; i < s2.length(); i++) {
    mp2[s2[i]]++;
  }
  bool set = true;
  for (char i = 'a'; i <= 'z'; i++) {
    if (mp1[i] < mp2[i]) {
      set = false;
      break;
    }
  }
  for (char i = 'A'; i <= 'Z'; i++) {
    if (mp1[i] < mp2[i]) {
      set = false;
      break;
    }
  }
  if (set) {
    cout << "YES"
         << "\n";
  } else {
    cout << "NO"
         << "\n";
  }
}
long long SubsetSum(long long arr[], long long n, long long sum,
                    long long **dp) {
  if (sum == 0) {
    return 1;
  }
  if (sum < 0) {
    return 0;
  }
  if (n <= 0) {
    return 0;
  }
  if (dp[n][sum] != -1) {
    return dp[n][sum];
  }
  bool ans1 = SubsetSum(arr, n - 1, sum - arr[n - 1], dp);
  bool ans2 = SubsetSum(arr, n - 1, sum, dp);
  bool ans = ans1 || ans2;
  dp[n][sum] = ans;
  return ans;
}
void q4() {
  long long n;
  cin >> n;
  long long arr[n];
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  if (sum % 2 != 0) {
    cout << "NO"
         << "\n";
  } else {
    long long sum2 = sum / 2;
    long long **dp = new long long *[n + 1];
    for (long long i = 0; i <= n; i++) {
      dp[i] = new long long[sum2 + 1]();
      for (long long j = 0; j <= sum2; j++) {
        dp[i][j] = -1;
      }
    }
    bool x = SubsetSum(arr, n, sum2, dp);
    if (x) {
      cout << "YES"
           << "\n";
    } else {
      cout << "NO"
           << "\n";
    }
  }
}
vector<long long> Digits(long long n) {
  long long m = n;
  vector<long long> ans;
  while (m) {
    ans.push_back(m % 10);
    m = m / 10;
  }
  return ans;
}
bool DistinctDigits(vector<long long> a) {
  bool set = true;
  sort(a.begin(), a.end());
  for (long long i = 0; i < a.size() - 1; i++) {
    if (a[i] == a[i + 1]) {
      set = false;
      break;
    }
  }
  return set;
}
void q5() {
  string s1, s2;
  cin >> s1 >> s2;
  vector<long long> diff;
  long long n1 = s1.length();
  long long n2 = s2.length();
  if (n1 != n2) {
    cout << "NO"
         << "\n";
    return;
  }
  for (long long i = 0; i < n1; i++) {
    if (s1[i] == s2[i]) {
      continue;
    } else {
      diff.push_back(i);
    }
  }
  if (diff.size() == 2) {
    long long i1 = diff[0];
    long long i2 = diff[1];
    if (s1[i1] == s2[i2] && s1[i2] == s2[i1]) {
      cout << "YES"
           << "\n";
    } else {
      cout << "NO"
           << "\n";
    }
  } else {
    cout << "NO"
         << "\n";
  }
}
