Harryxun/stf_run huggingface dataset:
n,m = map(int,input().split())
cards = []
for i in range(m):
    cards.append(list(map(int,input().split())))

min = cards[0][0]
max = cards[0][1]

for i in range(m):
    if cards[i][0] > min:
        min = cards[i][0]
    if cards[i][1] < max:
        max = cards[i][1]

if max >= min:
    print(max - min + 1)
else:
    print(0)

### FIXED CODE ###

a,b = map(int, input().split())
 
if a >= 13:
  print(b)
elif 6 <= a and a <= 12:
  print(int(b/2))
else:
  print(0)
N = int(raw_input())
H = list(map(int,raw_input().split()))
ans = []
count = 0
for i in range(0,N-1):

  for j in range(i,N-1):
    if H[j]>=H[j+1]:
      count = count + 1
    else:
      ans.append(count)
      count = 0
      break
    if j == N-2:
      ans.append(count)
      count = 0
print max(ans)

### FIXED CODE ###

N = int(raw_input())
H = list(map(int,raw_input().split()))
ans = []
count = 0
i = 0
while i <= N:
  if N == 1:
    ans.append(0)
    break
  if H[i] >= H[i+1]:
    count = count + 1
  else:
    ans.append(count)
    count=0
  i = i+1
  if i == N-1:
    ans.append(count)
    break

print max(ans)
(_,K),*T=[map(int,t.split())for t in open(0)]
A,B=map(sorted,t)
m,M,i=0,2**40,1
exec("i,M,m=((i+m)//2,i,m) if -sum(min(0,i-a*b)//b for a,b in zip(A,B[::-1]))<=K else((i+M)//2,M,i);"*41)
print(M)

### FIXED CODE ###

import math
N, K = map(int, input().split())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))[::-1]
Cs = [a*b for a, b in zip(As, Bs)]
BCs = list(zip(Bs, Cs))

def func(target):
    r = 0
    for b, c in BCs:
        r += math.ceil(max(0, c - target) / b)
    return r <= K

if __name__ == '__main__':
    min_i, max_i, index = 0, max(Cs)+1, 1
    while True:
        if func(index):
            index, max_i = (index-1 + min_i)//2, index-1
        else:
            index, min_i = (index+1 + max_i)//2, index+1
        if min_i > max_i:
            print(min_i)
            break
x,y = map(int,input().split())

ans=abs(abs(x)-abs(y))

if x<0 and y<=0 or x>=0 and y>0:
  if x>y:
    ans+=2

else:
  ans+=1
  
print(ans)

### FIXED CODE ###

s,t=input().split()
print(t+s)
from collections import deque

N = int(input())
T = [ [] for _ in range(N) ]
ans = []
for i in range(N-1):
    a,b = map(int,input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)
    ans.append([a-1,b-1])


color = [ [0]*N for _ in range(N)]
total = 0
q = deque()
q.append(0)

while(len(q) > 0):
    k = 0
    c = 1
    r = q.popleft()
    m = T[r][0]
    if r > m:
        k = color[r][m]
        T[r].remove(m)
    for j in T[r]:
        if c != k:
            color[r][j] = c
            color[j][r] = c
        else:
            c += 1
            color[r][j] = c
            color[j][r] = c
        c += 1
        q.append(j)
    total = max(total,c-1)

print(total)
for pair in ans:
    print(color[pair[0]][pair[1]])

### FIXED CODE ###

from collections import deque

N = int(input())
T = [ [] for _ in range(N) ]
ans = []
for i in range(N-1):
    a,b = map(int,input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)
    ans.append((a-1,b-1))


used = [0]*N
used[0] = 1
a = dict()
parent = [0]*N
total = 0
q = deque()
q.append(0)

while(len(q) > 0):
    c = 1
    r = q.popleft()
    for j in T[r]:
        if used[j] == 0:
            used[j] = 1
            if c == parent[r]:
                c += 1
            a[(r,j)] = c
            parent[j] = c
            c += 1
            q.append(j)
    total = max(total,c-1)


print(total)
for pair in ans:
    print(a[pair])
temp=list(map(int, input().stlip()))
a=temp[2]-(temp[0]-temp[1])
if a>=0:
  print(a)
else:
  print(0)

### FIXED CODE ###

temp=list(map(int, input().split()))
a=temp[2]-(temp[0]-temp[1])
if a>=0:
  print(a)
else:
  print(0)
a = input()
print("A" if ord(a) < 92 else "a") 



### FIXED CODE ###

N, K = map(int,input().split())
p = [int(i) for i in input().split()]
p.sort()
print(sum(p[:K]))
import fractions
a,b,c,d = map(int,input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def slove(x, y, z):
	return ans = (x//y) + (x//z) - (x//lcm(y,z))
print(slove(b,c,d) - slove(a-1,c,d))

### FIXED CODE ###

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def diff(i, j, k):
	return i - (i//j) - (i//k) + (i//lcm(j,k))

a,b,c,d = map(int, input().split())

print( diff(b, c, d) - diff(a-1, c, d) )
import collections

n = int(input())
List = [input() for i in range(n)]
res = []

c = collections.Counter(List)
m = 0
for v in c.values():
  m = max(m, v)
  
for k, v in c.items():
  if v == m:
    res.append(k)
    
res.sort()
for i in range(les(res)):
  print(res[i])

### FIXED CODE ###

import collections

n = int(input())
List = [input() for i in range(n)]
res = []

c = collections.Counter(List)
m = 0
for v in c.values():
  m = max(m, v)
  
for k, v in c.items():
  if v == m:
    res.append(k)
    
res.sort()
for i in range(len(res)):
  print(res[i])
import math
x,y=map(int,input().split())
if (2*y-x)%3==0 and (2*x-y)%3==0:
    a=(2*y-x)/3
    b=(2*x-y)/3
    ans=math.factorial(a+b)//math.factorial(a)//math.factorial(b)
    print(ans%(10**9+7))
else:
    print('0')

### FIXED CODE ###

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

x,y=map(int,input().split())
if (2*y-x)%3==0 and (2*x-y)%3==0 and  (2*y-x)/3>=0 and (2*x-y)/3>=0 :
    a=(2*y-x)//3
    b=(2*x-y)//3
    ans=cmb(a+b,a)
    print(ans%(10**9+7))
else:
    print('0')
import heapq
import copy
  
N = int(input())
ab = [[] * (N + 1) for i in range(N + 1)]
E = [0] * (N - 1)
for i in range(N - 1):
  a, b = map(int, input().split())
  ab[a].append(b)
  ab[b].append(a)
  E[i] = [a, b]
#print(ab)

#xとyを根とする部分木の頂点の数を求める
size = [1] * (N + 1)
def dfs_depandsize(tree,v,p):
    for x in tree[v]:
        if x == p:
            continue
        size[v] += dfs_depandsize(tree,x,v)
    return size[v]
dfs_depandsize(ab, 1, 0)
print(size)

#print(dfs(2, 3))
#(1 - (1/ 2) ** c) * (1 - (1/ 2) ** (N - c)) + 1
#上式を辺ごとに全て足し合わせたものがSの頂点の個数の期待値
#そこからN / 2を引けば求める期待値
#逆元を考える必要があるため、分母と分子に分けて考える

t = 2 ** N#分母
s = 0#分子
for i in range(N - 1):
  c = min(size[E[i][0]], size[E[i][1]])
  #print(c)
  s += (2 ** N + 1 - 2 ** (N - c) - 2 ** c) 
  
#辺の個数を数えたので、それに2 ** Nを足して、頂点の個数にする
#-1は空グラフをケア
s += 2 ** N - 1  
s -= N * 2 ** (N - 1)

#逆元計算
p = 10 ** 9 + 7
t_inv = pow(t, p-2, p)
ans = t_inv * s % p
print(ans)
  
    
    
    
    
    
    
  
  

### FIXED CODE ###

#解説方針#解法1
#https://qiita.com/ZhangChaoran/items/71fab0e4b8647a93d3a0
from collections import deque
from heapq import heappop, heappush
#標準入力
N = int(input())
MOD = 10 ** 9 + 7
L = [[] for i in range(N + 1)] #dfs用
for i in range(N - 1):
  a, b = map(int, input().split())
  L[a].append(b)
  L[b].append(a)

#木の探索
parent = [0] * (N + 1)
order = []
stack = [1]
while stack:
    x = stack.pop()
    order.append(x)  # 行きがけ順探索リスト
    for y in L[x]:
        if y == parent[x]:
            continue
        parent[y] = x  # 親ノードを記録
        stack.append(y)
#print(order, parent)

half = pow(2, MOD - 2, MOD)
power_inv = [1] * (N + 1)#2 ** N の逆元の集合
size = [1] * (N + 1)
for i, v in enumerate(order[::-1], 1):#iが1から
    p = parent[v]
    x = size[v]  # vの子孫ノード数（自分も含む）をとる
    size[p] += x  # 親にノード数を加算
    power_inv[i] = power_inv[i - 1] * half % MOD  # [1, 1/2, 1/4, ...]
#print(size)
# 辺iがSに含まれるための必要十分条件による辺の個数の期待値 
# (1 - (1/2) ** i)(1 - (1/2) ** (N - i))を展開して計算
# 根である1の頂点以外は、ある頂点とその親を結ぶ辺を考えた際
# i と N - i個の頂点に別れるので,size[2:]でOK
ans = sum((1 - power_inv[i] - power_inv[N - i] + power_inv[N]) %
          MOD for i in size[2:])  
#ans = sum((1 - (1/2) ** i- (1/2) ** (N - i) + (1/2) ** N) for i in size[2:])  
#print(ans)
ans += 1  # 木の頂点の個数は辺の個数+1
# -「すべての辺が含まれない、つまり空グラフの場合の誤加算」-N/2
ans -= power_inv[N] + N * power_inv[1]  
#ans -= N * power_inv[1]  
ans %= MOD

print(ans)
A, B, C = map(int, input())
if A*C <= B:
  print(C)
else:
  print(B//A)

### FIXED CODE ###

A, B, C = map(int, input().split())
if A*C <= B:
  print(C)
else:
  print(B//A)
d=int(input())
if d==25:
	print('Christmas')
elif d==24:
    print('Christmas Eve')
elif d==23:
    print('Christmas Eve Eve')
else d==22:
    print('Christmas Eve Eve Eve')

### FIXED CODE ###

d=int(input())
if d==25:
	print('Christmas')
elif d==24:
    print('Christmas Eve')
elif d==23:
    print('Christmas Eve Eve')
else:
    print('Christmas Eve Eve Eve')
a,b,c=map(int,input().split())
if a==b and b=c and c=a
  print(No)
elif a!=b and b!=c and c!=a
  print(No)
else:
  print(Yes)

### FIXED CODE ###

a,b,c=map(int,input().split())
if a==b and b==c and c==a:
  print("No")
elif a!=b and b!=c and c!=a:
  print("No")
else:
  print("Yes")
n = int(input())
s = ""
ac=0
wa=0
tle=0
re=0

for i in range(n):
    s = input()

    if s == 'AC':
        ac = ac+1
    elif s == 'TLE':
        tle = tle+1
    elif s == 'WA':
        wa = wa+1
    elif s == 'RE':
        re = re+1

print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

### FIXED CODE ###

n = int(input())

if n % 1000 == 0:
    print(0)
else:
    print(1000-n%1000)
if N/1000==0:
	N=0
else:
	N=(math.ceil(N/1000)+1)*1000-N
print("N")

### FIXED CODE ###

n = int(input())

if n % 1000 == 0:
  print(0)
else:
  print(1000-(n%1000))
import sys
import math

def dp(costs, K):
    table = [0]
    for i in range(1, len(costs)):
        min_cost = table[i-1] + abs(costs[i-1] - costs[i])
        for j in range(2, K + 1):
            jump = i - j
            if(jump >= 0):
                step = table[jump] + abs(costs[jump] - costs[i])
                min_cost = min([min_cost, step])
            else: 
                break
        table.append(min_cost)
    return table[-1]
        
def main():
    for index in range(2):
        line = input()
        if index == 0:
            K = int(line.split(" ")[1])
            continue
        costs = [int(s) for s in line.split(" ")]
        print(dp(costs, K))

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

def dp(costs):
    table = [0]
    for i in range(1, len(costs)):
        if i == 1:
            table.append(table[0] + abs(costs[0] - costs[1]))
            continue
        one_step = table[i-1] + abs(costs[i-1] - costs[i])
        two_step = table[i-2] + abs(costs[i-2] - costs[i])
        table.append(min([one_step, two_step]))
    return table[-1]
        
def main():
    for index, line in enumerate(sys.stdin):
        if index == 0:
            continue
        costs = [int(s) for s in line.split(" ")]
        print(dp(costs))

if __name__ == "__main__":
    main()
N, Q = map(int, input().split())
class_yoti = [[] for i in range(2 * 10 ** 5 + 1)]
A, B, C, D = [], [], [], []
max_rate = float('inf')

for i in range(N):
    tmpa, tmpb = map(int, input().split())
    A.append(tmpa), B.append(tmpb)
    class_yoti[tmpb].append(tmpa)

for i in range(Q):
    tmpa, tmpb = map(int, input().split())
    C.append(tmpa - 1), D.append(tmpb)

for i in range(2 * 10 ** 5 + 1):
    if class_yoti[i]:
        class_yoti[i].sort()
        if max_rate > class_yoti[i][-1]:
            max_rate = class_yoti[i][-1]

for i in range(Q):
    tmp = C[i]
    class_yoti[B[tmp]].remove(A[tmp])
    if class_yoti[B[tmp]]:
        class_yoti[B[tmp]].sort()

    B[tmp] = D[i]
    class_yoti[D[i]].append(A[tmp])
    class_yoti[D[i]].sort()

    max_rate = float('inf')
    for j in range(2 * 10 ** 5 + 1):
        if class_yoti[j]:
            max_rate = min(class_yoti[j][-1], max_rate)

    print(max_rate)



### FIXED CODE ###

from collections import Counter

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

A.sort()

ans = 0
tmp = [True for i in range(A[-1] + 1)]

for i in range(N - 1):
    if tmp[A[i]]:
        if A[i + 1] != A[i]:
            ans += 1
        for j in range(A[i], A[-1] + 1, A[i]):
            tmp[j] = False
if tmp[A[-1]]:
    ans += 1
print(ans)
# ref https://atcoder.jp/contests/agc025/submissions/7307839
import numpy as np
from card3.void.stop_watch import stop_watch

@stop_watch
def main():
    n = int(input())
    L, R = [], []
    for i in range(n):
        l, r = map(int, input().split())
        L.append(l)
        R.append(r)
    ll = np.array(L); ll.sort(); ll = ll[::-1]
    rr = np.array(R); rr.sort()

    lll = ll.cumsum()
    rrr = rr.cumsum()

    x = (lll - rrr).max()
    y = (lll[1:] - rrr[:-1]).max()
    z = (lll[:-1] - rrr[1:]).max()

    print(2 * max(x, y, z))
if __name__ == '__main__':
    main()

### FIXED CODE ###

# ref https://atcoder.jp/contests/agc025/submissions/7307839
import numpy as np

def main():
    n = int(input())
    L, R = [], []
    for i in range(n):
        l, r = map(int, input().split())
        L.append(l)
        R.append(r)
    ll = np.array(L); ll.sort(); ll = ll[::-1]
    rr = np.array(R); rr.sort()

    lll = ll.cumsum()
    rrr = rr.cumsum()

    x = (lll - rrr).max()
    y = (lll[1:] - rrr[:-1]).max()
    z = (lll[:-1] - rrr[1:]).max()

    print(2 * max(x, y, z))
if __name__ == '__main__':
    main()
a=[]
while True:
 n=input()
 if n=='0 ? 0':break
 a.append(n)
for s in a:
 t=s.split(' ')
 if t[1]=='/':
  print(t[0]//t[2])
 else:
  print(eval(''.join(t)))

### FIXED CODE ###

while 1:
 a=input()
 if'?'in a:break
 print(int(eval(a)))
N = int(input())
l = [list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        H = set()
        for k in range(len(l)):
            x = l[k]
            h = abs(i - x[0]) + abs(j - x[1]) + x[2]
            if h >= 1:
              H.add(h)
       
        if len(H) == 1:
          for x in H:
            h = x
          for k in range(len(l)):
            x = l[k]
            f = True
            f *= x[3] == max(0,h - abs(i - x[0]) - abs(j - x[1]))
        if f == True:
          print(i,j,h)

### FIXED CODE ###

N = int(input())
L = []
M = []
for _ in range(N):
    l = list(map(int,input().split()))
    if l[2] != 0:
        L.append(l)
    else:
        M.append(l)

for i in range(101):
    for j in range(101):
        tmp = -1
        for x in L:
            H = abs(x[0]-i) + abs(x[1]-j) + x[2]
            if H < 1:
                break
            if tmp != -1 and tmp != H:
                break
            else:
                tmp = H
        else:
            for x in L:
                if x[2]==max(0,H-abs(x[0]-i)-abs(x[1]-j)):
                    pass
                else:
                    break
            else:
                for x in M:
                    if x[2]==max(0,H-abs(x[0]-i)-abs(x[1]-j)):
                        pass
                    else:
                        break
                else:
                    print(i,j,H)
n, k = map(int, input().split())
l = list(map(int, input().split())).sort()
if n<=k :
    print(0)
else :
    sm = 0
    for i in range(n-k):
        sm += l[i]
    pritn(sm)

### FIXED CODE ###

n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
if n<=k :
    print(0)
else :
    sm = 0
    for i in range(n-k):
        sm += l[i]
    print(sm)
n = int(input())
s = input()
k = int(input())
for a in range(n) :
    if s[a] != s[k] :
        s = s[:a]+"*"+s[a+1:]
print(s)

### FIXED CODE ###

n = int(input())
s = input()
k = int(input())
for a in range(n) :
    if s[a] != s[k-1] :
        s = s[:a]+"*"+s[a+1:]
print(s)
s = input()
print(+1 if + else -1 if -)

### FIXED CODE ###

s = input()
print(s.count('+')*1+s.count('-')*-1)
input_line = input()
v1,v2,v3 = input_line.split(' ')
if v1+v2+v3 >= 22:
  print('bust')
else:
  print('win')

### FIXED CODE ###

input_line = input()
v1,v2,v3 = input_line.split(' ')
total = int(v1)+int(v2)+int(v3)
if total >= 22:
  print('bust')
else:
  print('win')
x = x**3
print(x)

### FIXED CODE ###

x = int(input())
y = x **3
print(y, end = "\n")
H,W,h,w=map(int,open(0));print((H-h)*(W-w))

### FIXED CODE ###

H,W=map(int,input().split())
h,w=map(int,input().split())
print((H-h)*(W-w))
#!/usr/bin/env python
x = int(input())
y = int(input())
if x % y  == 0 or x > 10**18:
	print(-1)
else:
	print(2*x)
	 


### FIXED CODE ###

#!/usr/bin/env python
x,y = map(int,input().split())
if x % y  == 0 or x > 10**18:
	print(-1)
else:
	print(x)
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for i in range(A+1):
    for j in range(B+1):
        for K in range(C+1):
            if ((500*i)+(100*j)+(50*k))==0:
                count+=1

print(count)

### FIXED CODE ###

A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if ((500*i)+(100*j)+(50*k))==X:
                count+=1

print(count)
def main():
    x, a = map(int, input().split())
    if x < a:
        print(0)
    else:
        print(10i)
   

if __name__ == "__main__":
    main()


### FIXED CODE ###


def main():
    x, a = map(int, input().split())
    if x < a:
        print(0)
    else:
        print(10)
   

if __name__ == "__main__":
    main()
n = int(input())
list = [int(input()) for 0 in range(n-1) ]
m = min(list)
a = 0
while True:
    m = m / 2
    if m <= 1:
        break
    a = a + 1
print(a)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
s = 0

def count(A, n):
    for i in range(n):
        if (A[i] % 2 == 1) or (A[i] == 0):
            return False
        A[i] = A[i] // 2
    return True

while True:
    if count(A, n):
        s += 1
    else:
        break
    
print(s)
N = int(input())
if N % 2 = 0:
  print(N)
else:
  print(N*2)

### FIXED CODE ###

N = int(input())
if N % 2 == 0:
  print(N)
else:
  print(N*2)
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, m = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    A = [list(map(int, input().split())) for i in range(m)]

    towns = {}
    for i in range(n):
        towns[i] = 0

    for j in range(m):
        for k in range(2):
            towns[A[j][k]] += 1

    print(towns.values())

resolve()

### FIXED CODE ###

def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, m = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    A = [list(map(int, input().split())) for i in range(m)]

    towns = {}
    for i in range(n):
        towns[i] = 0

    for j in range(m):
        for k in range(2):
            towns[A[j][k] -1] += 1

    for l in range(n):
        print(towns[l])
resolve()
tt=input()
a=''
while True:
    text=input().upper
    if text=='END_OF_TEXT':
        break
    a+=text
print(a.count(tt))

### FIXED CODE ###

import sys
a=input()
print(sys.stdin.read().upper().split().count(a.upper()))
n = int(input())
word = [input() for i in range(n)]

num = int(n / 2)
if word[:num] == word[num:] :
    print("Yes")
else : 
  	print("No")

### FIXED CODE ###

n = int(input())
word = str(input())

num = int(n / 2)
if word[:num] == word[num:] :
	print("Yes")
else :
	print("No")
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import copy

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.insert(場所,要素)
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
T = stdin.readline().rstrip()
num = int(stdin.readline().rstrip())
midcount = 1
res = []
ch = ''
for t in range(len(T)):
    if (ch == T[t] and t != 0):
        midcount += 1
    elif (ch != T[t] and t != 0):
        res.append(midcount)
        midcount = 1
    if (ch == T[t] and t == len(T) - 1):
        res.append(midcount)
    ch = T[t]

if (len(res) == 1):
    print(str(int(num * len(T) / 2)))
elif (T[0] == T[len(T) - 1]):
    counter = 0
    tes = []
    tes.append(res[0] + res[len(res) - 1])
    tes += res[1: len(res) - 1]
    for x in tes:
        counter += int(x / 2)
    counter *= num - 1
    for x in res:
        counter += int(x / 2)
    print(counter)
else:
    counter = 0
    for x in res:
        counter += int(x / 2)
    counter *= num
    print(counter)


### FIXED CODE ###

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import copy

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.insert(場所,要素)
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
T = stdin.readline().rstrip()
num = int(stdin.readline().rstrip())
midcount = 1
res = []
ch = ''
for t in range(len(T)):
    if (ch == T[t] and t != 0):
        midcount += 1
    elif (ch != T[t] and t != 0):
        res.append(midcount)
        midcount = 1
    if (ch == T[t] and t == len(T) - 1):
        res.append(midcount)
    ch = T[t]
if (len(T) == 1):
    res = [1]
if (len(res) == 1):
    print(str(int(num * len(T) / 2)))
elif (T[0] == T[len(T) - 1]):
    counter = 0
    tes = []
    tes.append(res[0] + res[len(res) - 1])
    tes += res[1: len(res) - 1]
    for x in tes:
        counter += int(x / 2)
    counter *= num - 1
    for x in res:
        counter += int(x / 2)
    print(counter)
else:
    counter = 0
    for x in res:
        counter += int(x / 2)
    counter *= num
    print(counter)
# -*- coding: utf-8 -*-
h, w = map(int, raw_input().split())

matrix = []
matrix.append('.'*(w+2))

for i in range(w):
    matrix.append('.' + raw_input() + '.')

matrix.append('.'*(w+2))

for i in range(1, h+1):
    for j in range(1, w+1):
        if matrix[i][j] == '#':
            if matrix[i+1][j] == '#' or matrix[i-1][j] == '#' or matrix[i][j-1] == '#' or matrix[i][j+1] == '#':
                continue
            else:
                print 'No'
                exit()
print 'Yes'

### FIXED CODE ###

#!/usr/bin/env python3
H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]

# yoko
for i in range(H):
    for j in range(W-1):
        if (M[i][j] == '#' or M[i][j] == 'M') and (M[i][j+1] == '#' or M[i][j+1] == 'M'):
            M[i][j] = 'M'
            M[i][j+1] = 'M'

#tate
for j in range(W):
    for i in range(H-1):
        if (M[i][j] == '#' or M[i][j] == 'M') and (M[i+1][j] == '#' or M[i+1][j] == 'M'):
            M[i][j] = 'M'
            M[i+1][j] = 'M'

ret = 0
for m in M:
    ret += m.count('#')

if ret == 0: print('Yes')
else: print('No')
r=list(map(int, input().split()))
print(r*r)

### FIXED CODE ###

r=int(input())
print(r*r)