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

S = input()

words = ['dreamer', 'eraser', 'dream', 'erase']

T = ''
T_next = ''

while len(T) < len(S):
    if len(T) + 5 > len(S):
        break
    for i in range(4):
        S_next = S[len(T):len(T + words[i])]
        T_next = words[i]
        #print(S_next)
        #print(T_next)
        #print()
        if (words[i] in words[0:1]) and (len(T + T_next) < len(S) and S[len(T + T_next)] == 'a'):
            pass
        elif S_next == T_next:
            T += T_next
            if T == S:
                print('YES')
                exit()
            break

print('NO')



### FIXED CODE ###

S = input()
S = S[::-1]

words = ['dreamer', 'eraser', 'dream', 'erase']
for i in range(4):
    K = words[i]
    words[i] = K[::-1]

T = ''
T_next = ''

while True:
    if len(T) + 5 > len(S):
        break
    for i in range(4):
        S_next = S[len(T):len(T + words[i])]
        T_next = words[i]
        flag = False
        #print(S_next)
        #print(T_next)
        #print()
        if S_next == T_next:
            flag = True
            T += T_next
            #print(T)
            #print()
            #input()
            if T == S:
                print('YES')
                exit()
            break
    if flag == False:
        break
    #input()

print('NO')
### BUGGY CODE ###

s = input()
k = len(s)
md = 10 ** 9 + 7
dp = [[0] * 13 for _ in range(k + 1)]
dp[0][0] = 1
for i, c in enumerate(s[::-1]):
    if c == "?":
        for n in range(10):
            m = n * 10 ** i % 13
            for j in range(13):
                dp[i + 1][j] += dp[i][j - m]
    else:
        m = int(c) * 10 ** i % 13
        for j in range(13):
            dp[i + 1][j] += dp[i][j - m]
    for j in range(13):
        dp[i + 1][j] %= md
print(dp[k][5])


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class mint:
    def __init__(self, x):
        self.__x = x % md

    def __str__(self):
        return str(self.__x)

    def __add__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x + other)

    def __sub__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x - other)

    def __rsub__(self, other):
        return mint(other - self.__x)

    def __mul__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * other)

    __radd__ = __add__
    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * pow(other, md - 2, md))

    def __rtruediv__(self, other):
        return mint(other * pow(self.__x, md - 2, md))

    def __pow__(self, power, modulo=None):
        return mint(pow(self.__x, power, md))

md = 10 ** 9 + 7

def main():
    s = SI()
    n = len(s)
    dp = [[0] * 13 for _ in range(n + 1)]
    # dp[i][m]...iケタ目までみたときに、余りがmになる数の個数
    dp[0][0] = mint(1)
    e10 = 1
    for i, c in enumerate(s[::-1]):
        for m in range(13):
            pre = dp[i][m]
            if pre == 0: continue
            if c == "?":
                for d in range(10):
                    nm = (m + d * e10) % 13
                    dp[i + 1][nm] += pre
            else:
                nm = (m + int(c) * e10) % 13
                dp[i + 1][nm] += pre
        e10 = e10 * 10 % 13
    print(dp[n][5])

main()
### BUGGY CODE ###

x = int(input())
if x <= 3:
  n = x
elif x == 4:
  n = 5
else:
  n = x
  j = 0
  while j == 0:
    a = int(n/2) + 1
    i = 2
    while i < a:
      if i == a-1:
        j = 1
        i = a
      elif n % i != 0:
        if i == 2:
          i += 1
        else:
          i += 2
      else:
        i = a
        if n % 2 == 0:
          n += 1
        else:
          n += 2
print(n)

### FIXED CODE ###

x = int(input())
if x <= 3:
  n = x
elif x == 4:
  n = 5
else:
  n = x
  j = 0
  while j == 0:
    a = int(n/2) + 1
    i = 2
    while i < a:
      if i == a-1:
        j = 1
        i = a
      elif n % i != 0:
        i += 1
      else:
        i = a
        n += 1
print(n)
### BUGGY CODE ###

import  math
K = int(input())

ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for l in range(1, K + 1):
            temp = math.gcd(i, j)
            temp2 = math.gcd(l, temp)
            ans += temp2
            
print(ans)

### FIXED CODE ###

from math import gcd
 
k=int(input())
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            ans += gcd(i, gcd(j,m))
print(ans)
### BUGGY CODE ###

import math
a, b, n = map(int, input().split())
ans = 0
for x in range(1, n + 1):
    tmp = math.floor(a * x / b) - a * math.floor(x / b)
    ans = max(ans, tmp)
print(ans)

### FIXED CODE ###

import math
a, b, n = map(int, input().split())
x = min(b - 1, n)
ans = math.floor(a * x / b) - a * math.floor(x / b)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,k = map(int,input().split())
h = tuple(map(int,input().split()))

dp = [0] + [float("inf")]*(n-1)
for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])

### FIXED CODE ###

n , k = map(int,input().split())
h = list(map(int,input().split()))
import numpy as np
h = np.array(h)
dp =np.zeros(n,dtype = int)
for i in range(1,n):
    s = max(0,i-k)
    dp[i] = np.min(dp[s:i] + np.abs(h[s:i] - h[i]))
print(dp[-1])
### BUGGY CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[1]:


N, Q = map(int, input().split())
abs_ = [list(map(int, input().split())) for _ in range(N-1)]
pxs_ = [list(map(int, input().split())) for _ in range(Q)]


# In[13]:


class Node:
    def __init__(self, nb, data): #コンストラクタ
        self.nb = nb
        self.data = data #ノードがもつ数値
        self.parent = -1 # nodeがrootのとき-1、それ以外番号
        self.childs = [] # childになるnode classが入る
        
    def connect_childs(self, child_class_):
        self.childs.append(child_class_)
        
    def get_childs(self):
        return self.childs
    
    def sum_data(self, data):
        self.data += data


# In[33]:


nodes = [Node(_+1, 0) for _ in range(N)]


# In[34]:


for i in range(N-1):
    a, b = abs_[i]
    nodes[a-1].connect_childs(nodes[b-1])
    nodes[b-1].parent = a-1


# In[25]:


"""
def sum_x(node, x):
    node.data += x
    for child in node.childs:
        sum_x(child, x)
"""


# In[28]:


"""
for i in range(Q):
    p, x = pxs_[i]
    sum_x(nodes[p-1], x)
"""


# In[35]:


for i in range(Q):
    p, x = pxs_[i]
    nodes[p-1].data += x


# In[36]:


def sum_data_to_childs(node):
    data = node.data
    for child in node.childs:
        child.data += data
        sum_data_to_childs(child)


# In[37]:


sum_data_to_childs(nodes[0])


# In[38]:


datas = [str(nodes[_].data) for _ in range(N)]
print(' '.join(datas))


# In[ ]:






### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[17]:


from sys import stdin
input = stdin.readline

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


# In[18]:


class Node:
    def __init__(self, nb, data): #コンストラクタ
        self.nb = nb
        self.data = data #ノードがもつ数値
        self.parent = -1 # nodeがrootのとき-1、それ以外番号
        #self.childs = [] # childになるnode classが入る
        
    #def connect_childs(self, child_class_):
    #    self.childs.append(child_class_)


# In[19]:


nodes = [Node(_+1, 0) for _ in range(N)]


# In[12]:


for i in range(N-1):
    a, b = map(int, input().split())
    #nodes[a-1].connect_childs(nodes[b-1])
    nodes[b-1].parent = a-1


# In[13]:


for i in range(Q):
    p, x = map(int, input().split())
    nodes[p-1].data += x


# In[14]:


def sum_data_to_childs(nodes):
    datas = [0]*N
    
    datas[0] = nodes[0].data
    
    for i in range(1, N):
        nodes[i].data += nodes[nodes[i].parent].data
        #print(nodes[i].data)
        datas[i] = nodes[i].data
        
    return datas


# In[15]:


datas = sum_data_to_childs(nodes)


# In[16]:


print(' '.join(map(str, datas)))


# In[20]:


#datas = [0] * N


# In[21]:


#child = [[]] * N


# In[22]:


#print(child)


# In[ ]:
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
ans = 0
for num in range(min(A), max(A)+1):
    tmp = [1 if abs(a-num)<=1 else 0 for a in A]
    ans = max(ans, sum(tmp))
print(ans)

### FIXED CODE ###

n = int(input())
A = sorted(list(map(int, input().split())))
count = dict()
for a in A:
    for i in range(a-1, a+2):
        if i not in count:
            count[i] = 1
        else:
            count[i] += 1
print(max(count.values()))
### BUGGY CODE ###

N = int(input())
lis = list(map(int,input().split()))
S = lis[0]
for i in range(2,N+1):
    S *= lis[i-1]
cnt = 0
while S % 2 == 0:
    S = S//2
    cnt += 1
print(cnt)


### FIXED CODE ###

N = int(input())
lis = list(map(int,input().split()))
cnt = 0
for i in range(N):
    while lis[i] % 2 == 0:
        lis[i] = lis[i]//2
        cnt += 1
print(cnt)
### BUGGY CODE ###

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

total = 0
flag = 0

for i in range(n):
  for j in range(n):
    if i == j:
      continue
    
    if int(a[i]/a[j]) == a[i]/a[j]:
      flag = 1
      break
    
  if flag == 0:
    total += 1
  else:
    flag = 0
    
print(total)

### FIXED CODE ###

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

max_a = max(a)
l = [0] * max_a

for i in range(n):
  j = 1
  while a[i] * j - 1 < max_a:
    l[a[i] * j - 1] += 1
    j += 1

count = 0

for i in range(n):
  if l[a[i] - 1] == 1:
    count += 1

print(count)
### BUGGY CODE ###

N = int(input())
List = list(map(int,input().split()))

ListK = [i+1+List[i] for i in range(N)]
ListL = [i+1-List[i] for i in range(N)]

from collections import Counter 
ans = 0
for i in range(N):
  ans += (Counter(ListK)[i])*(Counter(ListL)[i])

print(ans)  

### FIXED CODE ###

N = int(input())
List = list(map(int,input().split()))

ListK = [i+1+List[i] for i in range(N)]
ListL = [i+1-List[i] for i in range(N)]

from collections import Counter 
ans = 0

NewlistK = Counter(ListK)
NewlistL = Counter(ListL)

for i in range(N):
  ans += (NewlistK[i])*(NewlistL[i])

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

n = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
#print(L)

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

        l = j+1
        r = n-1
        m = (l + r) // 2

        while True:
            if l > r:
                #m = -1
                break
            m = (l + r) // 2
            if L[m] < length:
                l = m + 1
            else:
                r = m - 1

#        print(i, j, m)
        if m+1 < n and L[m+1] < length:
#            print('increment!')
            m += 1
        if L[m] >= length and L[m-1] < length:
            m -= 1
#            print('decrement!')
        if L[m] < length:
            #print('count up: ' + str(m - j) + '\n')
            ans += m - j

print(ans)

### FIXED CODE ###

import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
biSet = set()


for i in range(n):
    for j in range(i+1, n):
        length = l[i] + l[j]

        index = bisect.bisect_left(l[j+1:], length)
        #print(index)
        if index > 0:
            ans += index


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

import heapq
import sys

input = sys.stdin.readline

def dijkstra_heap(s,edge,n):
    #始点sから各頂点への最短距離
    d = [float('inf')] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

def main():
    N, M = map(int, input().split())
    edge = [[] * N for _ in range(N)]
    new_edge = [[] * N for _ in range(N)]
    for _ in range(M):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        edge[u].append(v)
    
    def dfs(s,now,cnt):
        if cnt == 3:
            new_edge[s].append((1,now))
            return

        for v in edge[now]:
            dfs(s,v,cnt+1)
    
    for i in range(N):
        dfs(i,i,0)
    S, T = map(int, input().split())
    S -= 1
    T -= 1
    d = dijkstra_heap(S,new_edge,N)
    if d[T] == float('inf'):
        print(-1)
    else:
        print(d[T])
    



if __name__ == "__main__":
    main()

### FIXED CODE ###

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


def main():
    N, M = map(int, input().split())
    edge = [[] for _ in range(N)]
    for _ in range(M):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        edge[u].append(v)

    S, T = map(int, input().split())
    S -= 1
    T -= 1
    dist = [[float('inf')] * 3 for _ in range(N)]
    dist[S][0] = 0
    q = deque([])
    q.append((S,0))
    while q:
        v, l = q.popleft()
        nl = (l + 1) % 3
        for nv in edge[v]:
            if dist[nv][nl] != float('inf'):
                continue
            dist[nv][nl] = dist[v][l] + 1
            q.append((nv,nl))
        
    
    if dist[T][0] == float('inf'):
        print(-1)
    else:
        print(dist[T][0] // 3)




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

N = int(input())
parts = [[] for i in range(3)]
con = [0] * N

ans = 0

for i in range(3):
  t = list(map(int,input().split()))
  parts[i] = t

under =parts[2]
middle = parts[1]
upper = parts[0]

for i in range(N):
  p = middle[i]
  for j in range(N):
    q = upper[j]
    if p > q:
      con[i] += 1
for i in range(N):
  p = under[i]
  for j in range(N):
    q = middle[j]
    if p > q:
      ans += con[j]

          
print(ans)

### FIXED CODE ###

import bisect

N = int(input())
parts = [[] for i in range(3)]
con = [0] * N

ans = 0

for i in range(3):
  t = sorted(list(map(int,input().split())))
  parts[i] = t

under =parts[2]
middle = parts[1]
upper = parts[0]

for i in range(N):
  p = middle[i]
  ans += bisect.bisect_left(upper,p) * (N - bisect.bisect_right(under,p))
    
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)
from functools import lru_cache

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

one = a.count(1)
two = a.count(2)
three = a.count(3)

@lru_cache(n**3)
def dfs(one,two,three):
    if one<0 or two<0 or three<0:
        return 0
    s = one+two+three
    if s == 0:
        return 0
    zero = n-s
    tmp = (one*dfs(one-1,two,three) + two*dfs(one+1, two-1, three) + three*dfs(one,two+1,three-1) + n)/(n - zero)
    return tmp

ans = dfs(one,two,three)
print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
a,b,c = c[1],c[2],c[3]
DP = [[[0]*(n+2) for i in range(n+2)] for j in range(n+2)]

for i in range(c+1):
    for j in range(n-a-i+1):
        for k in range(n-i-j+1):
            if i+j+k:
                DP[i][j][k] = (i*DP[i-1][j+1][k] + j*DP[i][j-1][k+1] + k*DP[i][j][k-1] + n)/(i+j+k)
print(DP[c][b][a])
### BUGGY CODE ###

n = int(input())
A = [[int(a),i] for i,a in enumerate(input().split())]
A.sort()
bit = [0]*(n+1)

def sum(i):
    # [0, i) の要素の総和を返す
    s = 0
    while i>0:
        s += bit[i]
        i -= i & -i
    return s
# 0 index を 1 index に変更  転倒数を求めるなら1を足していく
def add(i, x):
    i += 1
    while i <= n:
        bit[i] += x
        i += i & -i

# 総和がx以上になる位置のindex をbinary search
def bsearch(x):
    le = 0
    ri = 1<<(n.bit_length()-1)
    while ri > 0:
        if le+ri <= n and bit[le+ri]<x:
            x -= bit[le+ri]
            le += ri
        ri >>= 1
    return le+1 

ans = 0
for i in range(n):
    x,ind = A[i]
    s = sum(ind)
    if s == 0:
        l = 0
    else:
        l = bsearch(s)
    s2 = s+1
    if s2 > i:
        r = n
    else:
        r = bsearch(s2)-1
    ans += x*(r-ind)*(ind-l+1)
    add(ind,1)
print(ans)

### FIXED CODE ###

class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)
 
    def sum(self, i):
        # [0, i) の要素の総和を返す
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s
    # 0 index を 1 index に変更  転倒数を求めるなら1を足していく
    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    # 総和がx以上になる位置のindex をbinary search
    def bsearch(self,x):
        le = 0
        ri = 1<<(self.size.bit_length()-1)
        while ri > 0:
            if le+ri <= self.size and self.tree[le+ri]<x:
                x -= self.tree[le+ri]
                le += ri
            ri >>= 1
        return le+1

n = int(input())
a = [[int(x),i] for i,x in enumerate(input().split())]
a.sort()
bit = BIT(n)

ans = 0

for i in range(n):
    x,ind = a[i]
    s = bit.sum(ind)
    if s == 0:
        l = 0
    else:
        l = bit.bsearch(s)
    s2 = s+1
    if s2 > i:
        r = n
    else:
        r = bit.bsearch(s2)-1
    ans += x*(r-ind)*(ind-l+1)
    bit.add(ind,1)
    
print(ans)
### BUGGY CODE ###

from functools import reduce
n = input()
a = list(map(int,input().split()))
re = reduce((lambda x, y: x * y), a)
if re <= 1000000000000000000:
    print(re)
else:
    print("-1")


### FIXED CODE ###

# import numpy 
n = int(input())
a = list(map(int,input().split()))
re = 1
if 0 in a:
    print("0")
else:
    for i in a :
        re = re * i
        if re > 1000000000000000000:
            print("-1")
            quit()
    print(re)
### BUGGY CODE ###

import math
ans=0
a,b,n=map(int,input().split())

for i in range(n+1):
    keep=math.floor(a*i/b)-a*math.floor(i/b)
    if ans<keep:
        ans=keep
print(ans)

### FIXED CODE ###

import math
ans=-100000000
a,b,n=map(int,input().split())
i=min(n,b-1)
keep=math.floor(a*i/b)-a*math.floor(i/b)

print(keep)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
mod =10**9+7

b = [format(x,'b').zfill(60) for x in a]
b = [list(reversed(x)) for x in b]


ones = [0 for i in range(60)]
for x in b:
    for i in range(60):
        if x[i]=='1':
            ones[i] += 1

pow_two = [pow(2,i,mod) for i in range(60)]

ans = 0
for i in range(60):
    ans += ones[i]*(n-ones[i])*pow_two[i]
    ans %= mod
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
mod =10**9+7

b = [format(x,'b').zfill(60) for x in a]

ones = [0 for i in range(60)]
for x in b:
    for i in range(60):
        if x[59-i]=='1':
            ones[i] += 1

pow_two = [pow(2,i,mod) for i in range(60)]

ans = 0
for i in range(60):
    ans += ones[i]*(n-ones[i])*pow_two[i]
    ans %= mod
print(ans)
### BUGGY CODE ###

import math
from functools import reduce

k = int(input())
ans = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd(a,b,c)

print(ans)

### FIXED CODE ###

import math

k = int(input())

box = [0]*(k+1)
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        box[math.gcd(a,b)] += 1

for a in range(1,k+1):
    for c in range(1,k+1):
        ans += math.gcd(a,c)*box[a]

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

N,M = map(int,input().split())
X = []
for i in range(M):
  L,R = map(int,input().split())
  for j in range (R-L+1):
    X.append(L + j)
X_duplicate = [x for x in set(X) if X.count(x) > M-1]
print(len(X_duplicate))

### FIXED CODE ###

N,M = map(int,input().split())
L= 0
R = 10 ** 5
for i in range(M):
  Lm,Rm = map(int,input().split())
  L = max(L,Lm)
  R = min(R,Rm)
if R - L < 0:
  print(0)
else:
  print(R - L + 1)
### BUGGY CODE ###

def main():

  import collections

  N = int(input())
  S = list(input())

  CNT_S = collections.Counter(S)

  cnt_r = CNT_S['R']
  cnt_b = CNT_S['B']
  cnt_g = CNT_S['G']

  total = cnt_r * cnt_g * cnt_b
  subdu = 0


  for pos in range(N):
      for i in range(1, N):

          index_r = pos
          index_m = pos + i
          index_l = pos + 2 * i

          if (index_l < N and index_m < N and index_r < N):
              if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                  subdu += 1


  ans = total - subdu

  print(ans)
  
if __name__ == '__main__':
    main()



### FIXED CODE ###

import collections

N = int(input())
S = list(input())

CNT_S = collections.Counter(S)

cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']

total = cnt_r * cnt_g * cnt_b
subdu = 0


for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1


ans = total - subdu

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

N = int(input())
array = list(map(int,input().split()))

def func(c,result):
    num = max(array[0:c])
    idx = array.index(num)
    result += (-sum(array[idx+1:c]) + (num*(c-idx-1)))
    if idx == 0:
        print(result)
        return
    func(idx,result)
    
res = func(N,0)

### FIXED CODE ###

N = int(input())
array = list(map(int,input().split()))
new_array = array
t = sum(array)

for i in range(N-1):
    if array[i] > array[i+1]:
        array[i+1] = array[i]
print(sum(array) - t)
### BUGGY CODE ###

# coding: utf-8
import itertools
import math

N = int(input())
saidai = int(math.sqrt(N)) + 1

def g(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

def f(n):
    count = 0
    for (x, y, z) in itertools.product("".join(map(str, (range(1, saidai + 1)))), repeat=3):
        if g(int(x), int(y), int(z)) == n:
            count += 1
    return count

for i in range(1, N+1):
    print(f(i))



### FIXED CODE ###

# coding: utf-8
import itertools
import math

N = int(input())
saidai = int(math.sqrt(N)) + 1

def g(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

def f(n):
    result = [0] * (n+1)
    for idx, (x, y, z) in enumerate(itertools.product(range(1, saidai + 1), repeat=3)):
        tmp = g(int(x), int(y), int(z))
        if tmp <= N:
            result[tmp] += 1
    return result

res = f(N)
for i in range(1, N+1):
    print(res[i])
### BUGGY CODE ###

# -*- coding: utf-8 -*-


def main():
    """Function."""
    s = str(input())
    num = len(s)

    total = 0
    s_list = list(s)
    for _ in range(num):
        for i in range(num-1):
            end = num - i
            start = end - 2
            if s_list[start:end] == ["B", "W"]:
                total += 1
                s_list[start:end] = ["W", "B"]
    print(total)


if __name__ == "__main__":
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-


def main():
    """Function."""
    s = str(input())

    total = 0
    b_count = 0
    for i in range(len(s)):
        if s[i] == "B":
            b_count += 1
        if s[i] == "W":
            total += b_count

    print(total)


if __name__ == "__main__":
    main()