input: from collections import Counter
  def min_steps_to_achieve_k_periodic(word: str, k: int) -> int:
      """
      Given a string word with length n, and an integer k where k is a divisor of n.
  
      In a single operation, you can select two indices i and j that are multiples of k, then interchange the substring of length k starting at i with the one starting at j. Specifically, replace the substring word[i..i + k - 1] with word[j..j + k - 1].
  
      Determine the minimum number of operations needed to transform the word into a k-periodic string.
  
      A string is k-periodic if there exists a string s of length k such that word can be formed by repeating s any number of times. For example, if word == “ababab”, then word is 2-periodic for s = "ab".
      
      Examples:
      >>> word = "leetcodeleet", k = 4
      1
      >>> word = "leetcoleet", k = 2
      3
  
      Constraints:
      1 <= n == word.length <= 10^5
      1 <= k <= word.length
      k is a divisor of word.length.
      word includes only lowercase English letters.
      """
output:     
      n = len(word)
      substring_count = n // k
      min_operations = 0
  
      for i in range(k):
          char_count = Counter()
          for j in range(i, n, k):
              char_count[word[j]] += 1
          max_freq = max(char_count.values())
          min_operations += (substring_count - max_freq)
  
      return min_operations
  