import math import sys if __name__ == '__main__': N = int(input()) file = sys.stdin.readline().strip("\n") res = 0 blue = [0] red = [0] for ind, char in enumerate(file): blue.append(blue[-1] + int(char == "X")) red.append(red[-1] + int(char != "X")) # print(blue, len(blue)) # print(red, len(red)) # exit() for start in range(N): side = 3 end = start + side**2 - 1 while end < N: length = end - start + 1 # first ind is start # last ind is end # length is length # number of tiles is X[end + 1] - X[start] # print(start, end, length, file[start:end + 1]) # print("blue", blue[end + 1] - blue[start]) # print("red", red[end + 1] - red[start]) b = blue[end + 1] - blue[start] r = red[end + 1] - red[start] if length > 8 and math.sqrt(length)**2 == length: if (b == 4 * (math.sqrt(length) - 1) and r == length - 4 * (math.sqrt(length) - 1) or (r == 4 * (math.sqrt(length) - 1) and b == length - 4 * (math.sqrt(length) - 1))): res += 1 side += 1 end = start + side**2 - 1 # exit() # # for start in range(N): # blue = red = 0 # for end in range(start, N): # if file[end] == "X": # red += 1 # else: # blue += 1 # length = end - start + 1 # if length > 8 and math.sqrt(length)**2 == length: # if (blue == 4 * (math.sqrt(length) - 1) and red == length - 4 * (math.sqrt(length) - 1) or (red == 4 * (math.sqrt(length) - 1) and blue == length - 4 * (math.sqrt(length) - 1))): # res += 1 # # print(length, blue, red, file[start:end + 1]) # # file[start:end + 1] # # print(file[start:end + 1], end - start + 1) print(res)