fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define all(x) x.begin(), x.end()
  4. #define endl '\n'
  5. using namespace std;
  6. //the accepted call me.
  7.  
  8. void solve() {
  9. ios::sync_with_stdio(false);
  10. cin.tie(nullptr);
  11. //freopen("input.txt","r",stdin);
  12. //freopen("output.txt","w",stdout);
  13. string s1,s2;
  14. cin>>s1>>s2;
  15. int count1=0,count2=0;
  16. for(int i=0;i<s1.length();i++) {
  17. if (s1[i]!=s2[i]) {
  18. count1++;
  19. }
  20. }
  21. for(int i=0;i<s2.length();i++) {
  22. if (s1[i]!=s2[i]) {
  23. count2++;
  24. }
  25. }
  26. reverse(s2.begin(),s2.end());
  27. if (s1==s2) {
  28. cout<<s1.size()/2<<endl;
  29. return;
  30. }
  31. cout<<min(count1,count2)<<endl;
  32.  
  33. }
  34. int main() {
  35.  
  36. solve();
  37.  
  38. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
0