input: from typing import List
  
  def count_alternating_triplets(tiles: List[int]) -> int:
      """
      In a circular array of red and blue tiles, represented by an array of integers tiles, where:
  
      tiles[i] == 0 represents a red tile.
      tiles[i] == 1 represents a blue tile.
      An alternating triplet is defined as a sequence of 3 contiguous tiles with alternating colors (the tile in the middle differs in color from the tiles on either side of it).
  
      The function calculates the number of such alternating triplets in the circle.
  
      Note:
       Because the arrangement is circular, the first tile is treated as adjacent to the last tile.
  
      Examples:
      >>> tiles = [1,1,1]
      0
      >>> tiles = [0,1,0,0,1]
      3
  
      Constraints:
      3 <= tiles.length <= 100
      0 <= tiles[i] <= 1
      """
output:     
      n = len(tiles)
      count = 0
      
      for i in range(n):
          if tiles[i] != tiles[(i + 1) % n] and tiles[(i + 1) % n] != tiles[(i + 2) % n] and tiles[i] != tiles[(i + 2) % n]:
              count += 1
              
      return count
  