fork download
  1. # your code goes here
  2.  
  3.  
  4. K = int(input())
  5. s = input().strip()
  6. n = len(s)
  7. ans = 0
  8.  
  9. if K % 2:
  10. r = K // 2
  11. for c in range(r, n - r):
  12. i, j = c - r, c + r
  13. while i < j and s[i] == s[j]:
  14. i += 1
  15. j -= 1
  16. if i >= j:
  17. ans += 1
  18. else:
  19. r = K // 2
  20. for c in range(r, n - r + 1):
  21. i, j = c - r, c + r - 1
  22. while i < j and s[i] == s[j]:
  23. i += 1
  24. j -= 1
  25. if i >= j:
  26. ans += 1
  27.  
  28. print(ans)
  29.  
Success #stdin #stdout 0.08s 14076KB
stdin
5
ababab
stdout
2