def countingValleys(steps, path):
    # Write your code here
    result = 0
    check = 0
    
    for p in path:
        if p == 'U':
            if check + 1 == 0:
                result += 1
            check += 1
        else:
            check -= 1   
    
    return result
def pageCount(n, p):
    return min(p // 2, n//2 - p//2)

 

def sockMerchant(n, ar):
    # Write your code here
    d = dict()
    
    for s in ar:
        if d.get(s) is None:
            d[s] = 1
        else:
            d[s] += 1
        
    cnt = 0
    for _, v in d.items():
        cnt += v // 2
            
    return cnt

 

def bonAppetit(bill, k, b):
    # Write your code here
    actual = (sum(bill) - bill[k]) // 2
    
    result = b - actual
    
    if result > 0:
        print(result)
    else:
        print('Bon Appetit')
def dayOfProgrammer(year):
    # Write your code here
    if year == 1918:
        return '26.09.1918'
    
    check = False
    # Julian
    if ((year <= 1917) and (year % 4 == 0)):
        check = True
    # Gregorian
    elif (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)):
        check = True
       
    tday = 244 if check else 243
    
    return '{:02d}.09.{:04d}'.format(256 - tday, year)

 

def migratoryBirds(arr):
    # Write your code here
    return max(set(arr), key = arr.count)
def divisibleSumPairs(n, k, ar):
    # Write your code here
    
    # i < j
    cnt = 0
    for head in range(len(ar)):
        tail = head + 1
        while tail < n:
            if (ar[head] + ar[tail]) % k == 0:
                cnt += 1
                
            tail += 1
            
    return cnt
def birthday(s, d, m):
    # Write your code here
    cnt = 0
    for i in range(len(s) - m + 1):
        subset = sum(s[i:i + m])
        if subset == d:
            cnt += 1
            
    return cnt
def breakingRecords(scores):
    # Write your code here
    max_score = scores[0];min_score = scores[0]
    max_break = 0;min_break = 0
    
    for score in scores[1:]:
        if score > max_score:
            max_score = score
            max_break += 1       
        elif score < min_score:
            min_score = score
            min_break += 1
            
    return [max_break, min_break]
def getTotalX(a, b):
    # Write your code here
    def gcd(x, y):
        if x > y:
            s = y
            y = x
            x = s
        # x < y
        while(y > 0):
            x, y = y, x % y
        return x
    
    def lcm(x, y):
        return x * y // gcd(x, y)
    
    _lcm = a[0]
    for i in range(1, len(a)):
        _lcm = lcm(_lcm, a[i])
    
    if _lcm > 100:
        return 0
    
    _gcd = b[0]
    for i in range(1, len(b)):
        _gcd = gcd(_gcd, b[i])
            
    if (_gcd == 0) or (_lcm > _gcd):
        return 0 
    
    cnt = 0 
    for i in range(_lcm, _gcd + 1):
    	# b의 약수이고, a의 배수인 경우
        if (i % _lcm == 0) and (_gcd % i == 0):
            cnt += 1
            
    return cnt