Harryxun/stf_run huggingface dataset:
#input
N = int(input())
S = str(input())

#output
from collections import Counter
answer = 0
if N <= 3:
    continue
else:
    for i in range(N-2):
        for j in range(i+1, N-1):
            k = 2*j-i
            if S[i] == "R":
                if S[j] == "G":
                    answer += Counter(S[j+1:])["B"]
                    if k < N:
                        if S[k] == "B":
                            answer -= 1
                elif S[j] == "B":
                    answer += Counter(S[j+1:])["G"]
                    if k < N:
                        if S[k] == "G":
                            answer -= 1
            elif S[i] == "G":
                if S[j] == "R":
                    answer += Counter(S[j+1:])["B"]
                    if k < N:
                        if S[k] == "B":
                            answer -= 1
                elif S[j] == "B":
                    answer += Counter(S[j+1:])["R"]
                    if k < N:
                        if S[k] == "R":
                            answer -= 1
            elif S[i] == "B":
                if S[j] == "R":
                    answer += Counter(S[j+1:])["G"]
                    if k < N:
                        if S[k] == "G":
                            answer -= 1
                elif S[j] == "G":
                    answer += Counter(S[j+1:])["R"]
                    if k < N:
                        if S[k] == "R":
                            answer -= 1
                
print(answer)

### FIXED CODE ###

#input
N = int(input())
S = str(input())

#output
from collections import Counter
answer = 0
if N > 3:
    for i in range(1, N-1):
        if S[i] == "R":
            a = Counter(S[:i])["G"]
            b = Counter(S[i+1:])["B"]
            c = Counter(S[:i])["B"]
            d = Counter(S[i+1:])["G"]
            answer += a*b + c*d
            for j in range(1, min(i+1, N-i)):
                if S[i-j] != "R" and S[i+j] != "R" and S[i-j] != S[i+j]:
                    answer -= 1
        elif S[i] == "B":
            a = Counter(S[:i])["R"]
            b = Counter(S[i+1:])["G"]
            c = Counter(S[:i])["G"]
            d = Counter(S[i+1:])["R"]
            answer += a*b + c*d
            for j in range(1, min(i+1, N-i)):
                if S[i-j] != "B" and S[i+j] != "B" and S[i-j] != S[i+j]:
                    answer -= 1
        elif S[i] == "G":
            a = Counter(S[:i])["R"]
            b = Counter(S[i+1:])["B"]
            c = Counter(S[:i])["B"]
            d = Counter(S[i+1:])["R"]
            answer += a*b + c*d
            for j in range(1, min(i+1, N-i)):
                if S[i-j] != "G" and S[i+j] != "G" and S[i-j] != S[i+j]:
                    answer -= 1

print(answer)
N=int(raw_input())

A = [0 for i in range(N)]

for i in range(N):
    A[int(raw_input())-1]=(A[int(raw_input())-1]+1)%2

print sum(A)

### FIXED CODE ###

N=int(raw_input())
A = []
for i in range(N):
    A.append(int(raw_input()))

A.sort()
prev=A[0]
count=1
all_count=0
for i in range(1,N):
    if prev==A[i]:
        count+=1
    else:
        prev=A[i]
        all_count+=count%2
        count=1
all_count+=count%2

print all_count
from collections import defaultdict
import sys
input = sys.stdin.readline

N, M = [int(item) for item in input().split()]
A = [int(item) for item in input().split()]
A.sort()

new_dict = defaultdict(lambda: 0)
for i in range(M):
    b, c = [int(item) for item in input().split()]
    new_dict[c] += b
new_dict = sorted(new_dict.items(), key=lambda x: -x[0])


new_list = []
for k, v in new_dict:
    new_list += [k] * v
    if len(new_list) >= N:
        break

"""
new_list = new_list[:N]

#####

n = min(N, len(new_list))
for i in range(n):
    if A[i] >= new_list[i]:
        break
    A[i] = new_list[i]

print(sum(A))
"""


### FIXED CODE ###

from collections import defaultdict
import sys
input = sys.stdin.readline

N, M = [int(item) for item in input().split()]
A = [int(item) for item in input().split()]
A.sort()

new_dict = defaultdict(lambda: 0)
for i in range(M):
    b, c = [int(item) for item in input().split()]
    new_dict[c] += b
new_dict = sorted(new_dict.items(), key=lambda x: -x[0])

new_list = []
for k, v in new_dict:
    if v > N:
        v = N
    new_list += [k] * v
    if len(new_list) >= N:
        break

new_list = new_list[:N]

#####

n = min(N, len(new_list))
for i in range(n):
    if A[i] >= new_list[i]:
        break
    A[i] = new_list[i]

print(sum(A))
x = raw_input()
y = pow(x,3)
print 'y'

### FIXED CODE ###

x = int(raw_input())
print x ** 3
n = int(input())
a = list(map(int, input()))
ans = 0

for i in range(n):
    if a[i] % 2 == 1:
        continue

    temp = a[i]
    while temp % 2 == 0:
        temp %= 2
        ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(n):
    if a[i] % 2 == 1:
        continue

    temp = a[i]
    while temp > 0 and temp % 2 == 0:
        #print('temp: ' + str(temp))
        temp /= 2
        ans += 1

print(ans)
n=int(input())
if n==22:
    print("Christmas Eve Eve Eve")
if n==23:
    print("Christmas Eve Eve")
if n==24:
    print("Christmas Eve")
if n==25:
    print("
          Christmas")

### FIXED CODE ###

n=int(input())
if n==22:
    print("Christmas Eve Eve Eve")
if n==23:
    print("Christmas Eve Eve")
if n==24:
    print("Christmas Eve")
if n==25:
    print("Christmas")
N = int(input())
S = input()
l = len(S)
flg = 0
if l%2 == 1:
	flg = 1
	print("No")
else:
	for i in range(int(l/2)):
		//print(S[i],S[i+int(l/2)])
		if S[i] != S[i+int(l/2)]:	
			print("No")
			flg = 1
			break
if flg == 0:
	print("Yes")

### FIXED CODE ###

N = int(input())
S = input()
l = len(S)
flg = 0
if l%2 == 1:
	flg = 1
	print("No")
else:
	for i in range(int(l/2)):
		if S[i] != S[i+int(l/2)]:	
			print("No")
			flg = 1
			break
if flg == 0:
	print("Yes")
def main():
    input = input()
    if 0 <= input < 86400:
        hour = int(input / 3600)
        minute = int((input / 60) % 60)
        seconde = int(input % 60)
        print("{0}:{1}:{2}".format(hour,minute,seconde))

if __name__ == "__main__":
    main()

### FIXED CODE ###

input = int(input())
if 0 <= input < 86400:
    hour = input / 3600
    minute = (input / 60) % 60
    second = input % 60
    print("%d:%d:%d" % (hour,minute,second))
n, m = map(int, input())
c = set()
d = set()
for i in range(m):
    a, b = map(int, input())
    if a == 1:
        c.add(b)
    if b == n:
        d.add(a)
ans = "POSSIBLE" if len(c & d) else "IMPOSSIBLE"

### FIXED CODE ###

n, m = map(int, input().split())
c = set()
d = set()
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        c.add(b)
    if b == n:
        d.add(a)
ans = "POSSIBLE" if len(c & d) else "IMPOSSIBLE"
print(ans)
N, K = map(int, input().split())
h = list(map(int, input().split()))

memo = [-1 for _ in range(N)]

def dp(n):
  if memo[n] != -1:
    return memo[n]
  elif n != 0:
    m = min([dp(n-i)+abs(h[n]-h[n-i]) for i in range(1, min(K, n)+1)])
    memo[n] = m
    return m
  else:
    memo[n] = 0
    return memo[n]

print(dp(N-1))

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
c = [0]*N
for i in range(1, N):
    c[i] = min([c[j] + abs(h[i]-h[j]) for j in range(max(0, i-K), i)])
print(c[N-1])
N = int(input())
A = list(map(int, input().split()))
M = sum(A)/2
M
a = 0
i = 0
while a < M:
    a += A[i]
    i += 1
    
print(int(min(a-M,M-a+A[i])*2))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
M = sum(A)/2
M
a = 0
i = 0
while a < M:
    a += A[i]
    i += 1
    
print(int(min(a-M,M-a+A[i-1])*2))
from scipy.sparse.csgraph import csgraph_from_dense,dijkstra
from numpy.linalg import norm
from numpy import array
xs, ys, xt, yt = map(int, input().split())
N = int(input())
p=[(xs, ys, 0), (xt, yt, 0)]
edge = [[-1]*(n+2) for _ in range(n+2)]
edge[0][1] = edge[1][0] = norm(array([xs-xt, ys-yt]))
for i in range(N):
    x, y, r = map(int, input().split())
    for j in range(len(p)):
        x1, y1, r1 = p[j]
        edge[i+2][j] = edge[j][i+2] = max(norm(array([x-x1, y-y1]))-r-r1, 0.0)
    p.append((x, y, r))
G = csgraph_from_dense(edge,null_value=-1)  
print(dijkstra(G,indices=0)[1])   

### FIXED CODE ###

from scipy.sparse.csgraph import csgraph_from_dense,dijkstra

xs, ys, xt, yt = map(int, input().split())
n = int(input())

p = [(xs,ys,0),(xt,yt,0)]
for i in range(2,n+2):
    p.append(tuple(map(int,input().split())))
edge = [[-1]*(n+2)for i in range(n+2)]
 
for i in range(n+2):
    for j in range(i+1,n+2):
        edge[i][j] = edge[j][i] =  max(((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)**0.5 - p[i][2] - p[j][2],0.0)

#ここから
G = csgraph_from_dense(edge,null_value=-1)
print(dijkstra(G,indices=0)[1])
import itertools
X,K,D = map(int,input().split())
lst = lst = list(map(sum, itertools.product([0, 1], repeat=K)))
ans = 10**15
for i in range(2**K):
    x = 0
    p = 0; n = 0
    p = lst[i]*D
    n = (K-lst[i])*(-D)
    x = abs(X + n + p)
    if x < ans:
        ans = x
print(ans)

### FIXED CODE ###

X,K,D = map(int,input().split())
X = abs(X)
ans = 0
if X - D*K> 0:
    ans = X-D*K
else:
    count = X//D
    K -= count
    X -= count*D
    if K%2 == 1:
        X = abs(X-D)
    ans = X
print(ans)
N=input()
A=input()
B=N%500
if(B<A):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N=int(input())
A=int(input())
N!=0
B=int(N%500)
if(B <= A):
    print("Yes")
else:
    print("No")
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
s = p + q + r
S = sorted(s, reverse = True)
print(S)
i = 0
j = 0
ans = 0
a = 0
b = 0
c = 0
while i < (X + Y):
  if S[j] in r:
    c += 1
    r.remove(s[j])
    ans += S[j]
    i += 1
  elif S[j] in p and a < X:
    a += 1
    p.remove(S[j])
    ans += S[j]
    i += 1
  elif S[j] in q and b < Y:
    b += 1
    q.remove(S[j])
    ans += S[j]
    i += 1
  j += 1
print(ans)

### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse = True)
q = sorted(list(map(int, input().split())), reverse = True)
r = sorted(list(map(int, input().split())), reverse = True)
S = sorted(p[:X] + q[:Y] + r[:X+Y], reverse = True)
print(sum(S[:X+Y]))
x,y,z=map(int,imput().split())
print(z,x,y)

### FIXED CODE ###

x,y,z=map(int,input().split())
print(z,x,y)
N, M = map(int,input().split())
a, b = map(int,input().split())
l = list(range(a,b+1))  
for i in range(M-1):
  l2 = []
  c, d = map(int,input().split())
  l1 = list(range(c,d+1))  
  for j in l1:
    if j in l:
      l2.append(j)
  l = l2
print(len(l2))

### FIXED CODE ###

n, m = map(int,input().split())
a, b = map(int,input().split())
cnt = 0
for i in range(1, m):
  l, r = map(int,input().split())
  if (l > b and r > b) or (l < a and r < a):
    print(0)
    exit()
  if a<=l<=b:
    a = l
  if r <= b:
    b = r
print(b-a+1)
n = [int(input()) for _ in range(5)]
first_digit = []
for num in n:
    z = int(str(num)[-1])
    if z > 0:
        first_digit.append(z)

# print(first_digit)
t = 0
for i in range(len(n)):
    t += -(-n[i] // 10) * 10
print(t - (10 - min(first_digit)))


### FIXED CODE ###

n = [int(input()) for _ in range(5)]
first_digit = []
for num in n:
    z = int(str(num)[-1])
    if z > 0:
        first_digit.append(z)


# print(first_digit)
t = 0
for i in range(len(n)):
    t += -(-n[i] // 10) * 10
if len(first_digit) == 0:
    print(t)
else:
    print(t - (10 - min(first_digit)))
n=int(input())
t=[int(input()) for i in range(n)]
#print(n,t)
t.sort(reverse=True)

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
        
if n==1:
  ans=t
elif n==2:
  ans=t[0]/gcd(t[0],t[1])*t[1]
else:
  tmp=t[0]/gcd(t[0],t[1])*t[1]
  n=2
  while n < len(t):
    tmp=tmp/gcd(tmp,t[n])*t[n]
    n+=1  
  ans=tmp
  
print(int(ans))


### FIXED CODE ###

import fractions
n=int(input())

ans=1
for i in range(n):
  x=int(input())
  ans=ans//fractions.gcd(ans,x)*x

print(int(ans))
N = int(input())
S = str(input())
T = str(input())

for i in range(N):
	ST[i]   = S[i]
  	ST[i+1] = T[i]


### FIXED CODE ###

N = int(input())
S, T = map(str, input().split())

ST = ''

for i in range(N):
  ST += S[i]
  ST += T[i]

print(ST)
s = input()
before("Heisei")
after("TBD")
if s[7] == 1 or s[7] == 2 or s[7] == 3 or s[7] == 4:
    print(before)
else:
    print(after)

### FIXED CODE ###

s = input()
before = ("Heisei")
after = ("TBD")
if s[6] == "1" and s[5] == "0":
    print(before)
elif s[6] == "2" and s[5] == "0":
    print(before)
elif s[6] == "3":
    print(before)
elif s[6] == "4":
    print(before)
else:
    print(after)
import numpy as np
while 1:
    N = int(input())
    if N == 0:
        break
    xs = np.array(list(map(int, input().split())))
    
    print(np.sqrt(np.var(xs)))


### FIXED CODE ###

import math
while 1:
    N = int(input())
    if N == 0:
        break
    xs = list(map(int, input().split()))
    avg = 0
    for x in xs:
        avg += x
    avg /= len(xs)
    var = 0
    for x in xs:
        var += (x - avg) ** 2
    var /= len(xs)
    print(math.sqrt(var))
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[1000000000000000]*N
dp[0]=0
for i in range(N-1):
    for j in range(1,K+1):
        try:
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
        except:
            break
print(dp[N-1])

### FIXED CODE ###

N=int(input())
h=list(map(int,input().split()))
dp=[0]*N
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))
print(dp[N-1])
H = int(input())
A = int(input())
count = 0


while H > 0:
    H -= A
    count +=1
print(count)

### FIXED CODE ###

H,A = map(int,input().split())


count = 0

while H > 0:
    H -= A
    count +=1

print(count)
while True:
    (a, op, b) = input().split()
    a = int(a)
    b = int(b)

    if op = '?':
        break
    elif op = '+':
        print(a + b)
    elif op = '-':
        print(a - b)
    elif op = '*':
        print(a * b)
    elif op = '/':
        print(a // b)

### FIXED CODE ###

while True:
    (a, op, b) = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        print(a + b)
        pass
    elif op == '-':
        print(a - b)
        pass
    elif op == '*':
        print(a * b)
        pass
    else:
        print(a // b)
import sys

sys.setrecursionlimit = 10**6

n = int(input())
tr = [list() for _ in range(n)]
num = [None]*n
ran = [0]*n
par = [-1]*n
dep = [0]*n
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1; b -= 1
  tr[a].append(b)
  tr[b].append(a)
k = int(input())
root,c = map(int,input().split())
root -= 1
num[root] = c
def dfs(v,p,par,dep):
  for x in tr[v]:
    if x == p:
      continue
    par[x] = v
    dep[x] = dep[v] + 1
    dfs(x,v,par,dep)
  return
dfs(root,-1,par,dep)
for _ in range(k-1):
  v,c = map(int,input().split())
  v -= 1
  if abs(c-num[root]) > dep[v] or dep[v]%2 != (c-num[root])%2:
    print("No")
    exit(0)
  num[v] = c

def dfs2(v,p,ran):
  cur = [-10**9,10**9] if num[v] is None else [num[v],num[v]]
  if tr[v] == [p]: 
    ran[v] = tuple(cur)
    return
  for x in tr[v]:
    if x == p:
      continue
    dfs2(x,v,ran)
    if ran[x][0] > cur[0]:
      cur[0] = ran[x][0]
    if ran[x][1] < cur[1]:
      cur[1] = ran[x][1]
  cur[0] -= 1; cur[1] += 1
  ran[v] = tuple(cur)
  return

dfs2(root,None,ran)
  
q = [(root,None)]
while q:
  v,p = q.pop()
  for x in tr[v]:
    if x == p:
      continue
    if ran[x][0]<=num[v]+1<=ran[x][1]:
      num[x] = num[v] + 1
    elif ran[x][0]<=num[v]-1<=ran[x][1]:
      num[x] = num[v] - 1
    else:
      print("No")
      exit(0)
    q.append((x,v))
print("Yes")
for c in num:
  print(c)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6)

n = int(input())
tr = [list() for _ in range(n)]
num = [None]*n
ran = [0]*n
dep = [0]*n
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1; b -= 1
  tr[a].append(b)
  tr[b].append(a)
k = int(input())
root,c = map(int,input().split())
root -= 1
num[root] = c
def dfs(v,p,dep):
  for x in tr[v]:
    if x == p:
      continue
    dep[x] = dep[v] + 1
    dfs(x,v,dep)
  return
dfs(root,-1,dep)
for _ in range(k-1):
  v,c = map(int,input().split())
  v -= 1
  if abs(c-num[root]) > dep[v] or dep[v]%2 != (c-num[root])%2:
    print("No")
    exit(0)
  num[v] = c

def dfs2(v,p,ran):
  cur = [-10**9,10**9] if num[v] is None else [num[v],num[v]]
  if tr[v] == [p]: 
    ran[v] = tuple(cur)
    return
  for x in tr[v]:
    if x == p:
      continue
    dfs2(x,v,ran)
    if ran[x][0] > cur[0]:
      cur[0] = ran[x][0]
    if ran[x][1] < cur[1]:
      cur[1] = ran[x][1]
  cur[0] -= 1; cur[1] += 1
  ran[v] = tuple(cur)
  return

dfs2(root,None,ran)
  
q = [(root,None)]
while q:
  v,p = q.pop()
  for x in tr[v]:
    if x == p:
      continue
    if ran[x][0]<=num[v]+1<=ran[x][1]:
      num[x] = num[v] + 1
    elif ran[x][0]<=num[v]-1<=ran[x][1]:
      num[x] = num[v] - 1
    else:
      print("No")
      exit(0)
    q.append((x,v))
print("Yes")
for c in num:
  print(c)
N = int(input())
H = map(int, input().split())
#H = list(H)
tmp=[]
for i in range(len(H)-1, -1, -1):
    tmp.append(all([all(H[:i]<=H[i]), all(H[i]<=H[i+1:])]))
print(sum(tmp))

### FIXED CODE ###

import numpy as np
N = int(input())
H = np.array(list(map(int, input().split())))
tmp = []
for i in range(1, len(H)):
    tmp.append(all(H[:i]<=H[i]))
print(sum(tmp)+1)
import functools
import sys

sys.setrecursionlimit(200000)


class SearchProblem(object):
    def __init__(self, N, H):
        self.N = N
        self.H = H

    def isEnd(self, i):
        return i == self.N

    def succ(self, i):
        res = []
        if i + 1 <= self.N:
            res.append((i + 1, abs(self.H[i + 1] - self.H[i])))
        if i + 2 <= self.N:
            res.append((i + 2, abs(self.H[i + 2] - self.H[i])))
        return res


def solve(problem: SearchProblem):
    @functools.lru_cache(maxsize=None)
    def future_cost(s):
        if problem.isEnd(s):
            return 0
        else:
            return min(
                cost + future_cost(next_state) for next_state, cost in problem.succ(s)
            )

    return future_cost(1)


if __name__ == "__main__":
    N = int(input())
    H = [None] + [int(x) for x in input().split(" ")]
    problem = SearchProblem(N, H)
    print(solve(problem))


### FIXED CODE ###

def solve(n):
    table = [0 for i in range(N + 1)]
    for i in range(1, n + 1):
        if i == 1:
            table[1] = 0
        elif i == 2:
            table[2] = abs(H[2] - H[1])
        else:
            table[i] = min(
                table[i - 1] + abs(H[i] - H[i - 1]), table[i - 2] + abs(H[i] - H[i - 2])
            )
    return table[n]


if __name__ == "__main__":
    N = int(input())
    H = [0] + [int(x) for x in input().split(" ")]

    print(solve(N))
N, X = map(int, input().split())

a = [1]
p = [1]
for i in range(1, N+1):
    a.append(2 * a[i-1] + 3)
    p.append(2 * a[i-1] + 1)

def calc(N, X): #レベルNバーガーの下からX層に含まれるパティの枚数
    if N == 0: #全てパティ
        if X == 0:
            return 0
        else:
            return 1
    if X == 1:
        return 0
    # print (N - 1)
    if 1 <= X <= a[N - 1]:
        # print ('A')
        return calc(N - 1, X - 1)
    if X == 2 + a[N - 1]:
        # print ('B')
        return p[N - 1] + 1
    if 2 +a[N - 1] < X <= 2 + 2 * a[N - 1]:
        # print ('C')
        return p[N - 1] + 1 + calc(N - 1, max(X - 2 - a[N - 1]), 0)
    if X == 3 + 2 * 2 * a[N - 1]:
        # print ('D')
        return 2 * p[N - 1] + 1

print (calc(N, X))

### FIXED CODE ###

N, X = map(int, input().split())

a = [1]
p = [1]
for i in range(1, N+2):
    a.append(2 * a[i-1] + 3)
    p.append(2 * p[i-1] + 1)

def calc(N, X): #レベルNバーガーの下からX層に含まれるパティの枚数
    if N == 0: #全てパティ
        if X == 0:
            return 0
        else:
            return 1
    if X == 1:
        return 0
    # print (N - 1)
    if 1 < X <= 1 + a[N - 1]:
        # print ('A')
        return calc(N - 1, X - 1)
    if X == 2 + a[N - 1]:
        # print ('B')
        return p[N - 1] + 1
    if 2 + a[N - 1] < X <= 2 + 2 * a[N - 1]:
        # print ('C')
        return p[N - 1] + 1 + calc(N - 1, max(X - 2 - a[N - 1], 0))
    if X == 3 + 2 * a[N - 1]:
        # print ('D')
        return p[N]

print (calc(N, X))
def gcd(a, b):
	if a < b:
		a,b = b,a
	while b:
		a, b = b, a % b
	return a
def lcm(a, b): 
	return (a*b)//gcd(a,b)

a,b,c,d = map(int,input().split())
a3 = b // c - (a-1) // c
b3 = b // d - (a-1) // d
if c < d:
	c,d = d,c
width = b - a + 1
c3 = b//lcm(c,d) - (a-1)//lcm(c,d)
print(int(width - a3 - b3 + c3))

if __name__ == '__main__':
	main()

### FIXED CODE ###

def gcd(a, b):
	if a < b:
		a,b = b,a
	while b:
		a, b = b, a % b
	return a
def lcm(a, b): 
	return (a*b)//gcd(a,b)

a,b,c,d = map(int,input().split())
a3 = b // c - (a-1) // c
b3 = b // d - (a-1) // d
if c < d:
	c,d = d,c
width = b - a + 1
c3 = b//lcm(c,d) - (a-1)//lcm(c,d)
print(int(width - a3 - b3 + c3))
n,k = list(map(int, input().split()))
h = list(map(int, input().split()))
count = 0
for i in range(h):
    if h[i] >= k:
        count += 1
print(count)

### FIXED CODE ###

n,k = list(map(int, input().split()))
h = list(map(int, input().split()))
count = 0
for i in range(len(h)):
    if h[i] >= k:
        count += 1
print(count)
n = input()
ans=""
for i in range(len(n)):
    if n[i] == "D":
        ans = ans+"D"
    elif n[i] == "P":
        ans = ans+"P"
    elif n[i] == "?":
        if n[i-1]=="D" :
            if n[i+1]=="D"or"?":
                ans = ans+"P"
            else:
                ans = ans + "D"
        else:
            ans = ans + "D"
print(ans)

### FIXED CODE ###

n = input()
ans=""
for i in range(len(n)):
    if n[i] == "D":
        ans = ans+"D"
    elif n[i] == "P":
        ans = ans+"P"
    elif n[i] == "?":
        ans = ans+"D"
print(ans)
int(color) = input()
if color > 3200:
  print(color)
else:
  print('red')

### FIXED CODE ###

num = int(input())
color = input()
 
if num >= 3200:
  print(color)
else:
  print('red')
N,K=map(int,input().split())
a=[]
while K>0:
  d=int(input())
  b=list(map(int,input().split())
  a.extend(b)
  K=K-1
e=collection.counter(a)
print(N-len(e))

### FIXED CODE ###

import collections
N,K=map(int,input().split())
a=[]
d=[]
while K>0:
  K=K-1
  d.append(int(input()))
  b=list(map(int,input().split()))
  a.extend(b)
e=collections.Counter(a)
print(N-len(e))
import sys

s = sys.stdin.readline().rstrip()
n = len(s)

def main():
    m = n // 2
    if n & 1:
        l = s[m::-1]
        r = s[m:]
    else:
        l = s[m-1::-1]
        r = s[m:]
    base = l[0]
    
    cnt = m
    i = 0
    while i <= m:
        if l[i] == r[i] == base:
            i += 1
            cnt += 1
        else:
            break
    return cnt
    
if __name__ == '__main__':
    ans = main()
    print(ans)

### FIXED CODE ###

import sys

s = sys.stdin.readline().rstrip()
n = len(s)

def main():
    m = n // 2
    if n & 1:
        l = s[m::-1]
        r = s[m:]
    else:
        l = s[m-1::-1]
        r = s[m:]
    base = l[0]

    cnt = m
    i = 0
    if n & 1:
        m += 1
    while i < m:
        if l[i] == r[i] == base:
            i += 1
            cnt += 1
        else:
            break
    return cnt
    
if __name__ == '__main__':
    ans = main()
    print(ans)