from typing import List, Optional, Tuple, Dict, Set
from collections import defaultdict, Counter, deque
import heapq
import math
import bisect
import itertools
import functools


class Solution:
    def countPoints(self, rings: str) -> int:
        lst = []
        rgb = []
        count = 0
        for i in range(1, len(rings), 2):
            rgb = []
            if rings[i] not in lst:
                lst.append(rings[i])
                for j in range(1, len(rings), 2):
                    if rings[j] == rings[i]:
                        if rings[j - 1] == "R":
                            rgb.append(rings[j - 1])
                        if rings[j - 1] == "G":
                            rgb.append(rings[j - 1])
                        if rings[j - 1] == "B":
                            rgb.append(rings[j - 1])
                if len(set(rgb)) == 2:
                    count += 1
        return count
