Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

S = input()
count = 0

while '01' in S:
    count += 1
    S = S.replace('01', '', 1)

while '10' in S:
    count += 1
    S = S.replace('10', '', 1)

print(count * 2)

### FIXED CODE ###

S = input()

print(min(S.count('0'), S.count('1')) * 2)
### BUGGY CODE ###

import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, k = geta(int)
    a = tuple(geta(int))

    def update(b):
        r = [0] * n
        for i, bi in enumerate(b):
            i1 = max(0, i - bi)
            i2 = min(n - 1, i + bi)
            r[i1] += 1

            if i2 < n - 1:
                r[i2 + 1] -= 1

        for i in range(1, n):
            r[i] += r[i - 1]

        return r

    for i in range(k):
        a = update(a)

    print(*a, sep=" ")


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, k = geta(int)
    a = tuple(geta(int))

    def update(b):
        r = [0] * n
        for i, bi in enumerate(b):
            i1 = max(0, i - bi)
            i2 = min(n - 1, i + bi)
            r[i1] += 1

            if i2 < n - 1:
                r[i2 + 1] -= 1

        updated = (not r[0] == b[0])
        for i in range(1, n):
            r[i] += r[i - 1]
            if r[i] != b[i]:
                updated = True

        return r, updated

    for i in range(k):
        a, updated = update(a)
        if not updated:
            break

    print(*a, sep=" ")


if __name__ == "__main__":
    main()
### BUGGY CODE ###


import sys
input = sys.stdin.readline

def main():
    N,Q = list(map(int,input().split()))

    road = []
    x_list = []
    for i in range(N):
        s,t,x = list(map(int,input().split()))
        road.append((s-x,x,0))
        road.append((t-x,x,1))
        x_list.append(x)

    for i in range(Q):
        d = int(input())
        road.append((d,i,2))

    road.sort(lambda x:x[2])
    road.sort(lambda x:x[0])

    x_list = list(set(x_list))
    x_list.sort()

    x2i_dict = {}
    for i,x in enumerate(x_list):
        x2i_dict[x]=i


    class BIT:
            
        def __init__(self, L):
            self.N = len(L)
            self.bit = [0]*self.N
            for i,l in enumerate(L):
                self.add(i,l)

        def add(self, a, w):
            x = a + 1
            for i in range(1000):
                self.bit[x-1] += w
                x += x & -x
                if x > self.N:
                    break

        def sum(self, a):
            x = a+1
            ret = 0
            for i in range(1000):
                ret += self.bit[x-1]
                x -= x & -x
                if x <= 0:
                    break        
            return ret

    xn=len(x_list)

    bit = BIT([0]*xn)

    def bisectR(l,r):
        while r-l>1:
            if bit.sum((l+r)//2)>0:
                r = (l+r)//2
            else:
                l = (l+r)//2
        return r


    ans = [0]*Q
    for r in road:
        if r[2]==0:
             bit.add(x2i_dict[r[1]],1)
        elif r[2]==1:
            bit.add(x2i_dict[r[1]],-1)
        else:
            if bit.sum(xn-1)==0:
               ans[r[1]]=-1
            elif bit.sum(0)>0:
                ans[r[1]]=x_list[0]
            else:
                i = bisectR(0,xn-1)
                ans[r[1]] = x_list[i]
    for a in ans:
        print(a)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

def main():
    N,Q = list(map(int,input().split()))

    road = []
    x_list = []

    for i in range(N):
        s,t,x = list(map(int,input().split()))
        road.append([0,s-x,x])
        road.append([1,t-x,x])

    for i in range(Q):
        road.append([2,int(input()),i])

    from collections import defaultdict

    counter = defaultdict(int)
    counter[10**27] = 1
    ans = [0]*Q

    road.sort(key=lambda x:x[0])
    road.sort(key=lambda x:x[1])

    q = [10**27]

    from heapq import heappop,heappush

    for id,_,x in road:
        if id==0:
            heappush(q,x)
            counter[x]+=1
        elif id==1:
            counter[x]-=1
        else:
            while counter[q[0]]==0:
                heappop(q)
            #print(q)
            if q[0]<10**27:
                ans[x] = q[0]
            else:
                ans[x] = -1
    print("\n".join(map(str,ans)))

if __name__ == '__main__':
    main()
### BUGGY CODE ###

class UnionFind():
  def __init__(self, n):
    self.n=n
    self.p=[-1]*n

  def find(self,x):
    if self.p[x]<0:
      return x
    else:
      self.p[x]=self.find(self.p[x])
    return self.p[x]

  def same(self,x,y):
    return self.find(x)==self.find(y)

  def unite(self,x,y):
    x = self.find(x)
    y = self.find(y)
    if x==y:
      return

    if self.p[x]>self.p[y]:
      x,y=y,x

    self.p[x] += self.p[y]
    self.p[y] = x

  def members(self,x):
    p = self.find(x)
    return [i for i in range(self.n) if self.find(i)==p]

  def roots(self):
    return [i for i,x in enumerate(self.p) if x<0]

  def gcount(self):
    return len(self.roots())
 
  def uprint(self):
    print(self.p)
    return

n,m=map(int,input().split())
b=[[int(x) for x in input().split()] for y in range(m)]
u=n*(n-1)//2

s=[]
a=[u]
uf=UnionFind(n)

for i in range(m-1,0,-1):
  uf.unite(b[i][0]-1,b[i][1]-1)
  t = 0
  for j in uf.roots():
    n = len(uf.members(j))
    t += (n * (n-1)) // 2
  a.append(u-t)

a.reverse()
for i in range(len(a)):
  print(a[i])


### FIXED CODE ###

n, m = map(int, input().split())
e = [[int(x) for x in input().split()] for _ in range(m)]

u = [-1]*(n+1)

def find(x):
  return x if u[x] < 0 else find(u[x])

t = n*(n-1)// 2
s = [t]

for i in range(m-1,0,-1):
  a = find(e[i][0])
  b = find(e[i][1])
  if a > b:
    a, b = b, a
  if a != b:
    t -= u[a]*u[b]
    u[a] += u[b]
    u[b] = a
  s.append(t)

for i in reversed(s):
  print(i)
### BUGGY CODE ###

N, M = list(map(int,input().split()))
 
d = int(M/N)

def solve():
	i = 0
	while True:
		if M%(N+i+1) == 0:
			print(int(M/(N+i+1)))
			break
		i += 1

if M%N == 0:
	print(d)
else:
	solve()

### FIXED CODE ###

import math, sys, random

N, M = list(map(int,input().split()))
# N, M = 1111, 1000000000

def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True

d = int(math.floor(M/N))

if M%N == 0:
	print(d)
	sys.exit()

i = 0
f = False
while True:
	if M%(N+i+1) == 0:
		print(int(M/(N+i+1)))
		sys.exit()
	i += 1
	if i == 100000 and is_prime(M):
		print(1)
		sys.exit()
### BUGGY CODE ###

N = int(input())

A = [int(i) for i in input().split()]

c = 0
for i in range(N-1):
    for j in range(i+A[i], N):
        if abs(i-j) == A[i] + A[j]:
            c += 1
            
print(c)

### FIXED CODE ###

import collections
N = int(input())

A = [int(i) for i in input().split()]

plus = [0] * (N-1)
for i in range(N-1):
  plus[i] = i + A[i]

minus = [0] * (N-1)
for j in range(1, N):
  minus[j-1] = j - A[j]

sum = 0
c = dict(collections.Counter(minus))
for i in range(N-1):
  sum += c.get(plus[i], 0)
  c[minus[i]] -= 1

print(sum)
### BUGGY CODE ###

s = list(input())
q = int(input())
for i in range(q):
    line = list(input().split(" "))
    if line[0] == "1":
        s.reverse()
    elif line[1] == "1":
        s.insert(0,line[2])
    else:
        s.append(line[2])
for i in range(len(s)):
    print(s[i],end ="")
print()

### FIXED CODE ###

from collections import deque
s = deque(list(input()))
q = int(input())
sento = 0
for i in range(q):
    line = list(input().split(" "))
    if line[0] == "1":
        sento += 1
    elif line[1] == "1":
        if sento % 2 == 0:
            s.appendleft(line[2])
        else:
            s.append(line[2])
    else:
        if sento % 2 == 0:
            s.append(line[2])
        else:
            s.appendleft(line[2])
if sento % 2 ==1:
    s.reverse()
for i in range(len(s)):
    print(s[i],end ="")
print()
### BUGGY CODE ###

n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
ans=1000000000
for j in range(len(h)-2):
    c=h[j:j+k]
    ans=min(ans,max(c)-min(c))
print(ans)    

### FIXED CODE ###

n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
print(min([x-y for (x,y) in zip(h[k-1:],h[:-k+1])]))
### BUGGY CODE ###

a = input()
a = list(a)

s = a[0]
r = 1
cnt = 0
for l in range(len(a)):
    r =1
    s= a[l:l+r]
    s = "".join(s)

    while int(s)%2019 != 0 and r<=len(a)-1:
        s= a[l:l+r]
        s = "".join(s)
        if int(s)%2019 == 0:
            cnt +=1
            
        r += 1
    if l == r:
        r +=1
print(cnt)


### FIXED CODE ###

s = input()[::-1]

mod = 2019
ans = 0
d = 0
L = [0]
memo = [0]
for i in s:
    S =str(i)
    tmp = int(S)*pow(10,d,mod)%mod
    tmp = L[-1] + tmp
    L.append(tmp%mod)
    d +=1

from collections import Counter
L = Counter(L)

for v in L.values():
    ans +=v*(v-1)//2
print(ans)
### BUGGY CODE ###

N=int(input())
A=[int(x) for x in input().split()]
#重複始点終点調査
se=[]
for i in range(len(A)):
  if A[i]==sum(A)-N*(N+1)/2:
    se.append(i)
l=se[0]
r=se[1]

mod=10**9+7
 
#階乗計算
factorial=[1]
inverse=[1]
for i in range(1,N+2):
    factorial.append(factorial[-1]*i %mod)
    inverse.append((pow(factorial[i], mod-2, mod)))
#combination計算
def nCr(n,r):
  if n<r or n==0 or r==0:
    return 0
  return factorial[n] * inverse[r] * inverse[n-r] % mod

print(N)
for i in range(2,N+2):
    print(int(nCr(N+1,i)-nCr(l+N-r,i-1))%mod)


### FIXED CODE ###

N=int(input())
A=[int(x) for x in input().split()]
#重複始点終点調査
se=[]
c=sum(A)-N*(N+1)/2
for i in range(len(A)):
  if A[i]==c:
    se.append(i)
l=se[0]
r=se[1]

mod=10**9+7
 
#階乗計算
factorial=[1]
inverse=[1]
for i in range(1,N+2):
    factorial.append(factorial[-1]*i %mod)
    inverse.append((pow(factorial[i], mod-2, mod)))
#combination計算
def nCr(n,r):
  if n<r or n==0 or r==0:
    return 0
  return factorial[n] * inverse[r] * inverse[n-r] % mod

print(N)
for i in range(2,N+2):
    print(int(nCr(N+1,i)-nCr(l+N-r,i-1))%mod)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

class Event:
    def __repr__(self):
            return str(self.__dict__)

class User:
    def __repr__(self):
            return str(self.__dict__)

def solve():
    n, q = map(int, input().split())
    l_event = []
    for i in range(n):
        s, t, x = map(int, input().split())

        # 追加イベント
        e = Event()
        e.time = s-x
        e.type = 1 # add
        e.pos = x
        l_event.append(e)

        # 削除イベント
        e = Event()
        e.time = t-x
        e.type = -1 # delete
        e.pos = x
        l_event.append(e)

    l_user = []
    for i in range(q):
        d = int(input())

        # ユーザ評価イベント
        u = User()
        u.time = d + 0.5 # ユーザが出発する時刻までのイベントを先に処理したいので、0.5ずらす
        u.idx = i
        l_user.append(u)

    # リストを時刻でソート O(NlogN)
    l_event = sorted(l_event, key=lambda e: e.time)

    # ユーザも時刻でソート O(QlogQ)
    l_user = sorted(l_user, key=lambda e: e.time)

    ans = [-1]*q # 答えの配列
    s_stop = set()

    current_user_idx = 0

    # リストを順に処理する 全体 O(N + Qlog(2N))
    for e in l_event: # 中身が O(1) なら O(N)

        # 次処理するイベントの時刻より前のユーザをすべて処理する
        while(True): # この while 文は最大Q回しか回らないので、全体 O(Qlog(2N))
            if current_user_idx >= len(l_user):
                break
            u = l_user[current_user_idx]
            if u.time < e.time:
                if len(s_stop) != 0:
                    ans[u.idx] = min(s_stop) # O(log(2N))
                current_user_idx += 1
            else:
                break

        if e.type == 1: # add
            s_stop.add(e.pos)
        else: # delete
            s_stop.remove(e.pos)

    print("\n".join([str(a) for a in ans]))

solve()

### FIXED CODE ###

import sys;input=sys.stdin.readline

n,q=map(int, input().split())
event=[]
for _ in range(n):
    s,t,x=map(int,input().split())
    event.append((s-x-0.5,1,x))
    event.append((t-x-0.5,-1,x))
for i in range(q):
    event.append((int(input()),0,i))

event.sort()
is_stop=False
stop=set()
minstop=float('inf')
ans=[-1]*q
for t,e,x in event:
    if e > 0:
        stop.add(x)
        if x<minstop:
            minstop=x
            is_stop=True
    elif e<0:
        stop.remove(x)
        if minstop==x:
            is_stop=False
    elif len(stop)>0:
        if not is_stop:
             minstop=min(stop)
             is_stop=True
        ans[x]=minstop

print('\n'.join(map(str, ans)))
### BUGGY CODE ###

import copy

N=int(input())
L=[]
tmp=[]
for i in range(N):
  L.append(int(input()))

for i in range(N):
  tmp=copy.deepcopy(L)
  del tmp[i]
  print(max(tmp))

### FIXED CODE ###

N=int(input())
L=[]
for _ in range(N):
  L.append(int(input()))
sL=sorted(L)
sL.reverse()
m=max(L)
m2=sL[1]

for i in range(N):
  if L[i]==m:
    print(m2)
  else:
    print(m)
### BUGGY CODE ###

from collections import deque

s = deque(input())
q = int(input())
for _ in range(q):
    query = input().split()
    if query[0] == '1':
        s.reverse()
    else:
        if query[1] == '1':
            s.appendleft(query[2])
        else:
            s.append(query[2])
print(''.join(s))


### FIXED CODE ###

from collections import deque

is_reverse = False
s = deque(input())
q = int(input())
for _ in range(q):
    query = input().split()
    if query[0] == '1':
        is_reverse = not is_reverse
    else:
        if (not is_reverse and query[1] == '1') or (is_reverse and query[1] == '2'):
            s.appendleft(query[2])
        else:
            s.append(query[2])
print(''.join(s)[::-1]) if is_reverse else print(''.join(s))
### BUGGY CODE ###

n,m = map(int,input().split())
h = list(map(int,input().split()))
route = []
cnt = 0
for i in range (m):
    s = list(map(int,input().split()))
    route.append(s)
for i in range(1,n+1):
    c = 0
    for j in range(m):
        if i in route[j]:
            a = route[j].index(i)
            if a == 0:
                A = route[j][0]
                B = route[j][1]
            else:
                A = route[j][1]
                B = route[j][0]
            if h[A-1]<=h[B-1]:
                c +=1
    if c == 0:
        cnt +=1
print(cnt)

### FIXED CODE ###

n,m = map(int,input().split())
h = list(map(int,input().split()))
route = []
lower = []
cnt = 0
for i in range (m):
    s = list(map(int,input().split()))
    if h[s[0]-1] > h[s[1]-1]:
        lower.append(s[1])
    elif h[s[1]-1] > h[s[0]-1]:
        lower.append(s[0])
    elif h[s[1]-1] == h[s[0]-1]:
        lower.append(s[0])
        lower.append(s[1])
low = list(set(lower))
cnt =n-len(low)
print(cnt)
### BUGGY CODE ###

def listxor(a):
    count = [0] * (len(max(a))-2)
    
def checkxor(a,b):
    zero = set([0])
    for x in a:
        temp = set()
        for y in zero:
            temp.add(x^y)
        zero |= temp
    one = set([0])
    for x in b:
        temp = set()
        for y in one:
            c = x ^ y
            if c not in zero:
                return False
            else:
                temp.add(x^y)
        one |= temp
    return True

T = int(input())
for i in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    S = input()
    if S[-1] == '1':
        print('1')
    elif S.count('0') == len(S):
        print('0')
    else:
        zeros = []
        ones = []
        for j in range(len(S)):
            if S[j] == '1':
                ones.append(A[j])
                current = 1
                break
        for k in range(j+1,len(S)):
            if S[k] == '1':
                if current == 1:
                    ones.append(A[k])
                else:
                    if checkxor(zeros,ones) == False:
                        print('1')
                        break
                    else:
                        ones.append(A[k])
                        current = 1
            else:
                if current == 0:
                    zeros.append(A[k])
                else:
                    zeros.append(A[k])
                    current = 0
        if checkxor(zeros,ones) == False:
            print('1')
        else:
            print('0')

### FIXED CODE ###

T = int(input())
for i in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    S = input()
    base = []
    for i in range(1,N+1):
        temp = A[-i]
        for x in base:
            temp = min(temp,temp^x)
        if temp != 0:
            if S[-i] == '1':
                print('1')
                break
            else:
                base.append(temp)
    else:
        print('0')
### BUGGY CODE ###

inf = float('inf')
mod = 10**9+7
from itertools import product, permutations, combinations, combinations_with_replacement
import bisect


N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for i in range(N)]

result = -inf

kireisa = 0
oishisa = 0
ninkido = 0

for i in combinations(range(N), M):

    kireisa = 0
    oishisa = 0
    ninkido = 0
    for j in i:
        kireisa += xyz[j][0]
        oishisa += xyz[j][1]
        ninkido += xyz[j][2]
    tmp = abs(kireisa)+abs(oishisa)+abs(ninkido)
    result = max(result,tmp)

print(result)
 

### FIXED CODE ###

N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for i in range(N)]
tmp = [[0]*N for i in range(8)]

for n, _ in enumerate(xyz):
    x,y,z = _
    tmp[0][n] = x+y+z
    tmp[1][n] = x+y-z
    tmp[2][n] = x-y+z
    tmp[3][n] = x-y-z
    tmp[4][n] = -x+y+z
    tmp[5][n] = -x+y-z
    tmp[6][n] = -x-y+z
    tmp[7][n] = -x-y-z

result = -float("inf")
for i in range(8):
    result = max(result, sum(sorted(tmp[i], reverse=True)[:M]))
print(result)
### BUGGY CODE ###

n=int(input())
a = []
for i in range(n):
    a.append(input())
a_count = [a.count(i) for i in a]
print('\n'.join(sorted(set([a[i] for i in range(len(a_count)) if a_count[i] == max(a_count)]))))


### FIXED CODE ###

d=dict()
for i in range(int(input())):
    s=input()
    if s not in d:
        d[s]=1
    else:
        d[s]+=1
max_v = max(d.values())
print(*sorted([kv[0] for kv in d.items() if kv[1] == max_v]))
### BUGGY CODE ###

def make_divisors(n):
	divisors = []
	for i in range(1, int(n**0.5)+1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n//i)

	divisors.sort()
	return divisors

x = int(input())

l = make_divisors(x)

for i in range(max(len(l)//2,1)):
	a = -10**4+l[i]
	b = -10**4
	#print(a,b)
	while True:
		num = a**4 + (a**3)*b + (a**2)*(b**2) + a*(b**3) + b**4
		if num == l[-i-1]:
			print(a,b)
			#print('Yes!')
			break
		if a == 10**3:
			break
		#print(l[-i-1],num)
		a += 1
		b += 1



### FIXED CODE ###

def make_divisors(n):
	divisors = []
	for i in range(1, int(n**0.5)+1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n//i)

	divisors.sort()
	return divisors

x = int(input())

l = make_divisors(x)

for i in range(max(len(l)//2,1)):
	a = -10**3+l[i]
	b = -10**3
	#print(a,b)
	while True:
		num = a**4 + (a**3)*b + (a**2)*(b**2) + a*(b**3) + b**4
		if num == l[-i-1]:
			print(a,b)
			#print('Yes!')
			break
		if b == 10**3:
			break
		#print(l[-i-1],num)
		a += 1
		b += 1
### BUGGY CODE ###

N , K = map( int , input().split())
lst = list(map(int, input().split()))
ans = 10 ** 9
for i in range(N - K + 1):
    # Ｋ個のサブリストを作成する
    lst2 = lst[i: i+K]
    # 全て正（先頭がゼロ以上）であれば、最大の正数（一番右の数）が最小時間となる
    if lst2[0] >= 0:
        ans = min(ans, lst2[-1])
    # 全て負（一番右がゼロ以下）であれば、最小の整数（一番左の数）が最小時間となる
    elif lst2[-1] <= 0:
        ans = min(ans, abs(lst2[0]))
    # 上記以外は、正負混在のケース    
    else:
        #  一番右の方が大きいとき
        if abs(lst2[0]) < lst2[-1]:
            # 負の方向から折り返してくる方が最小なので
            ans = min(ans , abs(lst2[0]) * 2 + lst2[-1])
        else:
            # 正の方向から折り返してくる方が最小なので
            ans = min(ans , abs(lst2[0]) + lst2[-1] * 2)

print(ans)


### FIXED CODE ###

import numpy as np
N , K = map( int , input().split())
lst = list(map(int, input().split()))
ans = 10 ** 9

for i in range(N - K + 1):
    # 全て正（先頭がゼロ以上）であれば、最大の正数（一番右の数）が最小時間となる
    if lst[i] >= 0:
        ans = min(ans, lst[i + K -1])
    # 全て負（一番右がゼロ以下）であれば、最小の整数（一番左の数）が最小時間となる
    elif lst[i + K -1] <= 0:
        ans = min(ans, abs(lst[i]))
    # 上記以外は、正負混在のケース    
    else:
        #  一番右の方が大きいとき
        if abs(lst[i]) < lst[i + K -1]:
            # 負の方向から折り返してくる方が最小なので
            ans = min(ans , abs(lst[i]) * 2 + lst[i + K -1])
        else:
            # 正の方向から折り返してくる方が最小なので
            ans = min(ans , abs(lst[i]) + lst[i + K -1] * 2)

print(ans)
### BUGGY CODE ###

n = int(input())
s = input()

R=[]
G=[]
B=[]

for i in range(n):
    if s[i] == "R":
        R.append(i)
    elif s[i] == "G":
        G.append(i)
    else:
        B.append(i)

ans = len(R)*len(G)*len(B)
for i in range(n-2):
    for j in range(i+1,n-1):
        k  = 2*j-i
        if k<n:
            s1,s2,s3 = s[i],s[j],s[k]
            if (s1!=s2) and (s1!=s3) and (s2!=s3):
                ans-=1
print(ans)

### FIXED CODE ###

n = int(input())
s = input()

R=[]
G=[]
B=[]

for i in range(n):
    if s[i] == "R":
        R.append(i)
    elif s[i] == "G":
        G.append(i)
    else:
        B.append(i)

ans = len(R)*len(G)*len(B)
for i in range(n-2):
    for j in range(i+1,n-1):
        k  = 2*j-i
        if k<n:
            if (s[i]!=s[j]) and (s[i]!=s[k]) and (s[j]!=s[k]):
                ans-=1
print(ans)
### BUGGY CODE ###

n,m,q=map(int,input().split())
data=[[0 for i in range(n+1)] for j in range(n+1)]
for _ in range(m):
    l,r=map(int,input().split())
    data[l][r]+=1

for _ in range(q):
    x,y=map(int,input().split())
    ans=0
    for i in range(x,y+1):
        for j in range(x,y+1):
            ans+=data[i][j]           
    print(ans)
    

### FIXED CODE ###

n,m,q=map(int,input().split())
data=[[0 for i in range(n+1)] for j in range(n+1)]
for _ in range(m):
    l,r=map(int,input().split())
    data[l][r]+=1

for i in range(n+1):
    for j in range(1,n+1):
        data[i][j]+=data[i][j-1]
for i in range(n+1):
    for j in range(1,n+1):
        data[j][i]+=data[j-1][i]

for _ in range(q):
    x,y=map(int,input().split())
    print(data[y][y]-data[x-1][y]-data[y][x-1]+data[x-1][x-1])
### BUGGY CODE ###

MOD = 10 ** 9 + 7
S = input()
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1

for i in range(len(S)):
    tmpS = 0
    if S[i] == '?':
        tmpS = -1
    else:
        tmpS = int(S[i])
    for j in range(10):
        if tmpS != -1 and tmpS != j: continue
        for k in range(13):
            dp[i + 1][(k * 10 + j) % 13] += dp[i][k]
            dp[i + 1][(k * 10 + j) % 13] %= MOD

print(dp[len(S)][5])

### FIXED CODE ###

S = input()
INF = 10 ** 9 + 7

dp = [[0 for _ in range(13)] for _ in range(len(S) + 1)]
index = 1
dp[0][0] = 1
for i in range(len(S)):
    c = S[-i - 1]
    if c == '?':
        for j in range(10):
            for k in range(13):
                dp[i + 1][(j * index + k) % 13] += dp[i][k]
                dp[i + 1][(j * index + k) % 13] %= INF
    else:
        c = int(c)
        for k in range(13):
            dp[i + 1][(c * index + k) % 13] += dp[i][k]
            dp[i + 1][(c * index + k) % 13] %= INF
    index *= 10
    index %= 13

print(dp[len(S)][5])