input: Write a Python function that takes a 0-indexed n x n grid of integers (where n is odd and each element is either 0, 1, or 2) and returns the minimum number of operations required to transform the grid so that it forms the letter Y. The letter Y is defined such that all cells belonging to the Y (composed of two diagonals converging at the center and a vertical line from the center to the bottom) have the same value, all other cells have the same value, and the values of the Y and non-Y cells are different. Each operation can change a cell's value to 0, 1, or 2.
  
  Example:
  >>> grid = [[1,2,2],[1,1,0],[0,1,0]]
  3
  >>> grid = [[0,1,0,1,0],[2,1,0,1,2],[2,2,2,0,1],[2,2,2,2,2],[2,1,2,2,2]]
  12
  
  Constraints:
  3 <= n <= 49
  n == grid.length == grid[i].length
  0 <= grid[i][j] <= 2
  n is odd.
output: def min_operations_to_y(grid):
      from collections import Counter
          
      n = len(grid)
      center = n // 2
      
      y_indices = set()
      for i in range(center + 1):
          y_indices.add((i, center))
          if i != center:
              y_indices.add((i, center - i))
              y_indices.add((i, center + i))
      for i in range(center, n):
          y_indices.add((i, center))
      
      y_counts = Counter()
      non_y_counts = Counter()
      
      for i in range(n):
          for j in range(n):
              if (i, j) in y_indices:
                  y_counts[grid[i][j]] += 1
              else:
                  non_y_counts[grid[i][j]] += 1
      
      min_operations = float('inf')
      for y_val in [0, 1, 2]:
          for non_y_val in [0, 1, 2]:
              if y_val != non_y_val:
                  operations = (sum(y_counts.values()) - y_counts[y_val]) + (sum(non_y_counts.values()) - non_y_counts[non_y_val])
                  min_operations = min(min_operations, operations)
      
      return min_operations