Harryxun/stf_run huggingface dataset:
import numpy as np
N, K = map(int, input().split())
N_lis=np.zeros(N)
for i in range(K):
  d=int(input())
  sweet=np.arrray(map(int, input().split()))
  sweet-=1
  for j in sweet:
    N_lis[j]+=1

no_sweet=N_lis[N_lis==0]
print(no_sweet.sum())


 

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
N_lis=np.zeros(N)
for i in range(K):
    d=int(input())
    sweet=np.array(list(map(int, input().split())))
    #print(sweet)
    sweet-=1
    for j in sweet:
        N_lis[j]+=1
#print(N_lis)
no_sweet=N_lis==0
#print(no_sweet)
print(no_sweet.sum())
l, n = map(int, input().split())
s = sorted([input() for _ in range(n)])
print("".join(s))

### FIXED CODE ###

N, _ = [int(x) for x in input().split()]
S = sorted([input() for _ in range(N)])
print(''.join(S))
#include <bits/stdc++.h>
using namespace std;
int H, W;

int main() {
    cin >> H >> W;
    vector<vector<int>> a(H + 1, vector<int>(W + 1));
    vector<vector<int>> b(H + 1, vector<int>(W + 1, 0));
    for(int i = 0; i < W + 1; i++){
        a.at(H).at(i) = 1;
    }
    for(int j = 0; j < H; j++){
        string str;
        cin >> str;
        a.at(j).at(W) = 1;
        for(int i = 0; i < W; i++){
            if(str.at(i) == '.')
                a.at(j).at(i) = 0;
            else
                a.at(j).at(i) = 1;
        }
    }

    //横方向
    for(int j = 0; j < H; j++){
        int prev = 1;
        int start = 0;
        for(int i = 0; i < W + 1; i++){
            if (a.at(j).at(i) == 0){
                if(prev == 1){
                    start = i;
                    prev = 0;
                }
            }else{
                if(prev == 0){
                    int num = i - start;
                    for(int k = start; k < i; k++){
                        b.at(j).at(k) = num;
                    }
                    prev = 1;
                }
            }
        }
    }

    //縦方向
    for(int i = 0; i < W; i++){
        int prev = 1;
        int start = 0;
        for(int j = 0; j < H + 1; j++){
            if (a.at(j).at(i) == 0){
                if(prev == 1){
                    start = j;
                    prev = 0;
                }
            }else{
                if(prev == 0){
                    int num = j - start;
                    for(int k = start; k < j; k++){
                        b.at(k).at(i) += num - 1;
                    }
                    prev = 1;
                }
            }
        }
    }

    int ans = 0;
    for(int j = 0; j < H; j++){
        int m1 = *max_element(b.at(j).begin(), b.at(j).end());
        ans = max(ans, m1);
    }
    cout << ans << endl;
}

### FIXED CODE ###

import numpy as np
import sys


def get_data(stream):
    buf = b''
    b = stream.buffer.read(1)
    while b != b'\n':
        buf += b
        b = stream.buffer.read(1)
    H, W = map(int, buf.split())
    c = stream.buffer.read(H * (W + 1))
    arr = np.array(c.split())
    arr = np.frombuffer(arr, dtype='S1').reshape((H, W))
    return H, W, arr


def main():
    H, W, arr = get_data(sys.stdin)
    a = arr == b'.'
    L = np.empty((H, W), dtype='i8')
    R = np.empty((H, W), dtype='i8')
    T = np.empty((H, W), dtype='i8')
    B = np.empty((H, W), dtype='i8')
    T[0] = a[0]
    for i in range(1, H):
        T[i] = (T[i - 1] + 1) * a[i]
    B[-1] = a[-1]
    for i in range(H - 2, -1, -1):
        B[i] = (B[i + 1] + 1) * a[i]
    L[:, 0] = a[:, 0]
    for i in range(1, W):
        L[:, i] = (L[:, i - 1] + 1) * a[:, i]
    R[:, -1] = a[:, -1]
    for i in range(W - 2, -1, -1):
        R[:, i] = (R[:, i + 1] + 1) * a[:, i]

    print((T + B + L + R - 3).max())


if __name__ == "__main__":
    main()
from collections import deque

G = dict()
N, M = map(int, input().split())
color = [0]*(N+1)
for n in range(1, N+1):
    G[n] = []
for _ in range(M):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
Q = int(input())

for _ in range(Q):
    v, d, c = map(int, input().split())
    # BFS
    dist = dict()
    deq = deque([v])
    color[v] = c
    dist[v] = 0
    while len(deq) > 0:
        s = deq.popleft()
        if dist[s] >= d:
            break
        for t in G[s]:
            if t in dist.keys()
                pass
            else:
                dist[t] = dist[s] + 1
                color[t] = c
                deq.append(t)
                
for n in range(1, N+1):
    print(color[n])
                


### FIXED CODE ###

from collections import deque

G = dict()
N, M = map(int, input().split())
color = [0]*(N+1)
for n in range(1, N+1):
    G[n] = []
for _ in range(M):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
Q = int(input())




data = [list(map(int, input().split())) for _ in range(Q)]
data.reverse()
color_d = [-1]*(N+1)

for v, d, c in data:
    if color_d[v] >= d:
        pass
    # BFS
    deq = deque([v])
    if color[v] == 0:
        color[v] = c
    color_d[v] = d
    while len(deq) > 0:
        s = deq.popleft()
        for t in G[s]:
            if color_d[t] >= color_d[s] - 1:
                pass
            else:
                color_d[t] = color_d[s] - 1
                if color[t] == 0:
                    color[t] = c
                if color_d[t] > 0:
                    deq.append(t)
                
for n in range(1, N+1):
    print(color[n])
N,M =map(int, input().split())
a = [input().split() for l in range(M)]

for i in range(M):
    for j in range(2):
        a[i][j]=int(a[i][j])

a.sort()
for i in range(M-1):
    if a[i]==a[i+1]:
        a[i]=[0,0]
ans = 10**(N-1)

for i in range(M):
    if a[i][0]==1 ans a[i][1]!=0:
        ans += (a[i][1]-1)*10**(N-a[i][0])
    else:
        ans += a[i][1]*10**(N-a[i][0])

for i in range(M):
    for j in range(M-i):
        if a[i][0] == a[i+j][0] and a[i][1] != a[i+j][1]:
            ans = -1

for i in range(M):
    if a[i][0]==1 and a[i][1]==0:
        ans = -1

if M == 0 and N ==1:
    ans = 0

print(ans)

### FIXED CODE ###

import sys
N,M =map(int, input().split())
a = [input().split() for l in range(M)]

for i in range(1000):
    flag = 1
    b = str(i)
    if len(b)!= N:
        flag = 0
        continue
    for j in range(M):
        if b[int(a[j][0])-1] != a[j][1]:
            flag = 0
            break
    if flag == 1:
        print(i)
        sys.exit()

print("-1")
def cmb(n, k, mod):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n - i)) % mod

    denominator = 1
    for i in range(1, k + 1):
        denominator = (denominator * i) % mod

    return (numerator * pow(denominator, mod - 2, mod)) % mod


import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
freq = {}
for i in a:
    if i in freq:
        freq[i] += 1
    else:
        freq[i] = 1

inf = 1001001001
dp = [inf for _ in range(20005)]
dp2 = [inf for _ in range(20005)]
mod = 10**9 + 7

base = 0
for k, v in freq.items():
    dp[k] = cmb(v, 2, mod)
    dp2[k] = cmb(v - 1, 2, mod)
    base += dp[k]

# print(dp)

for i in a:
    print(base - dp[i] + dp2[i])


### FIXED CODE ###

# def cmb(n, k, mod):
#     numerator = 1
#     for i in range(k):
#         numerator = (numerator * (n - i)) % mod

#     denominator = 1
#     for i in range(1, k + 1):
#         denominator = (denominator * i) % mod

#     return (numerator * pow(denominator, mod - 2, mod)) % mod


def ncr(n, r):
    r = min(r, n - r)
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + i + 1 for i in range(r)]
    denominator = [i + 1 for i 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 *= numerator[k]
    return int(result)


import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
freq = {}
for i in a:
    if i in freq:
        freq[i] += 1
    else:
        freq[i] = 1

inf = 1001001001
dp = [inf for _ in range(200005)]
dp2 = [inf for _ in range(200005)]
mod = 10**13 + 3

base = 0
for k, v in freq.items():
    if v > 2:
        dp[k] = ncr(v, 2)
        dp2[k] = ncr(v - 1, 2)
    elif v == 2:
        dp[k] = 1
        dp2[k] = 0
    else:
        dp[k] = 0
        dp2[k] = 0
    base += dp[k]

for i in a:
    print(base - dp[i] + dp2[i])
S, T = input().split()
if len(S) == len(T) - 1:
    Slis = list(S)
    Tlis = list(T)
    Tlis.remove(Tlis[ - 1])
    if Slis  ==Tlis:
        print('Yes')
    else:
        print('No')
else:
    print('No')

### FIXED CODE ###

S = input()
T = input()
 
Slis = list(S)
Tlis = list(T)
Tlis.pop(-1)
if len(S) == 0:
    print('No')
elif Slis  == Tlis:
    print('Yes')
else:
    print('No')
s  = input()
t = input()
result = len([e for a,b in zip(s,t) if a != b])
print(result)

### FIXED CODE ###

s = input()
t = input()
result = len([a for a,b in zip(s,t) if a != b])
print(result)
def solve():
    N,M,K = map(int,input().split())
    MOD = 998244353

    fac, finv, inv = COMinit(N,MOD)

    ans = 0
    for i in range(K+1):
        ans += M % MOD * pow(M-1,N-1-i,MOD) % MOD * COM(N-1,i,MOD,fac,finv,inv) % MOD
    
    print(ans%MOD)

# COMの前処理
# テーブルを作る
# O(n)
def COMinit(N, mod):
    fac = [0] * N
    finv = [0] * N
    inv = [0] * N

    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1

    for i in range(2, N):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod
    
    return fac, finv, inv

# nCrを計算 前処理としてCOMinitの実行が必要
# O(1)
def COM(n, r, mod, fac, finv, inv):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
if __name__ == '__main__':
    solve()

### FIXED CODE ###

def solve():
    N,M,K = map(int,input().split())
    MOD = 998244353

    fac, finv, inv = COMinit(N+1,MOD)

    ans = 0
    for i in range(K+1):
        ans += M % MOD * pow(M-1,N-1-i,MOD) % MOD * COM(N-1,i,MOD,fac,finv,inv) % MOD
    
    print(ans%MOD)

# COMの前処理
# テーブルを作る
# O(n)
def COMinit(N, mod):
    fac = [0] * N
    finv = [0] * N
    inv = [0] * N

    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1

    for i in range(2, N):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod
    
    return fac, finv, inv

# nCrを計算 前処理としてCOMinitの実行が必要
# O(1)
def COM(n, r, mod, fac, finv, inv):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
if __name__ == '__main__':
    solve()
def f(n):
  return (n**2-n)//2
ans=0
N=int(input())
d=dict()
for i in range(N):
  s=sorted(input())
  if s not in d:
    d[s]=0
  d[s]+=1
for i in d:
  ans+=f(i)
print(ans)

### FIXED CODE ###

N=int(input())
d=dict()
ans=0
for _ in range(N):
  s=input()
  s=tuple(sorted(s))
  if s in d:
    d[s]+=1
  else:
    d[s]=0
for i in d.values():
  ans+=(int(i)**2+int(i))/2
print(int(ans))
x = int(input())
a = 3.14*x*x
b = 3.14*(x+x)

print("%.6f" %a, "%.6f" %b)

### FIXED CODE ###

import math
pi = math.pi

x = float(input())

a = pi*x*x
b = pi*(x+x)

print("{0:0.6f} {1:0.6f}".format(a, b))
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
A = np.insert(A, 0, 0)

flg = [False for _ in range(N + 1)]
town = []
i = 1
while flg[i] == False:
    town.append(i)
    flg[i] = True
    i = A[i]
else:
    s = i
    to_s = town.index(s)
    loop = len(town) - to_s

if len(town) >= K:
    print(town[K])
else:
    print(town[(K - to_s) % loop + to_s])

### FIXED CODE ###

import sys
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
A = np.insert(A, 0, 0)

flg = [False for _ in range(N + 1)]
town = []
i = 1
cnt = 0
for _ in range(N):
    town.append(i)
    flg[i] = True
    i = A[i]

if len(town) >= K:
    print(town[K])
else:
    s = i
    to_s = town.index(s)
    loop = len(town) - to_s
    print(town[(K - to_s) % loop + to_s])
a,v=map(int,input().split())
b,w==map(int,input().split())
t=int(input())
d=abs(a-b)
if d<=(v-w)*t:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
d=abs(a-b)
if d<=(v-w)*t:
  print('YES')
else:
  print('NO')
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    System.out.println(x + y/2);
  }
}

### FIXED CODE ###

x, y = map(int, input().split())
print(x + y//2)
n=input()
print(48-n)

### FIXED CODE ###

M=int(input())
print(24+(24-M))
N = input()
A = list(map(int, input().split()))

cnt = 0
while True: 
    odd_flag = False
    for i in range(N):
        if A[i] % 2 == 1:
            odd_flag = True
    if odd_flag:
        break
    for i in range(N):
        A[i] = A[i] // 2
    cnt += 1

print(cnt)


### FIXED CODE ###

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

cnt = 0
while True: 
    odd_flag = False
    for i in range(N):
        if A[i] % 2 == 1:
            odd_flag = True
    if odd_flag:
        break
    for i in range(N):
        A[i] = A[i] // 2
    cnt += 1

print(cnt)
import math

def solve():
    ans = [-1 for i in range(n+1)]
    remaining = set(range(1, n+1))
    remaining.remove(1)
    last_visited = [1]
    last_visited2 = []
    c = 0
    while remaining:
        print(remaining)
        for r in last_visited:
            for ad in adj[r]:
                if ad in remaining:
                    last_visited2.append(ad)
                    remaining.remove(ad)
                    ans[ad] = r
        last_visited = last_visited2
        last_visited2 = []
        c += 1
    if -1 in ans[2:]:
        print("No")
        return
    print("Yes")
    for i in ans[2:]:
        print(i)
    return

n, m = [int(ii) for ii in input().split()]
adj = [[] for _ in range(n + 1)]
for i in range(m):
    a, b = [int(ii) for ii in input().split()]
    adj[a].append(b)
    adj[b].append(a)
solve()

### FIXED CODE ###

import math

def solve():
    ans = [-1 for i in range(n+1)]
    remaining = set(range(1, n+1))
    remaining.remove(1)
    last_visited = [1]
    last_visited2 = []
    while remaining:
        c = len(remaining)
        for r in last_visited:
            for ad in adj[r]:
                if ad in remaining:
                    last_visited2.append(ad)
                    remaining.remove(ad)
                    ans[ad] = r
        last_visited = last_visited2
        last_visited2 = []
        if len(remaining) == c:
            print("No")
            return
    print("Yes")
    for i in ans[2:]:
        print(i)
    return

n, m = [int(ii) for ii in input().split()]
adj = [[] for _ in range(n + 1)]
for i in range(m):
    a, b = [int(ii) for ii in input().split()]
    adj[a].append(b)
    adj[b].append(a)
solve()
def solve(x, y, d, m):
    ret = ""
    for i in range(m):
        if x + y >= 0 and x - y >= 0:
            ret += "R"
            x -= d[i]
        elif x + y >= 0 and x - y < 0:
            ret += "U"
            y -= d[i];
        elif x + y < 0 and x - y >= 0:
            ret += "D"
            y += d[i];
        else:
            ret += "L"
            x += d[i]
    print (ret)


def main():
    m = 34
    X, Y, d = [], [], []

    for i in range(32, 0, -1):
        d += [2**i]
    d += [1]

    N = int(input())
    even, odd = 0, 0

    for i in range(N):
        x, y = map(int, input().split())
        X += [x]; Y += [y]
    
        if (abs(x) + abs(y)) % 2 == 0:
            even += 1
        else:
            odd += 1

    if even and odd:
        print(-1)
        return 0

    if odd:
        m -= 1

    print(m)
    print(" ".join(map(str, d)))

    for i in range(N):
        solve(X[i], Y[i], d, m)

main()


### FIXED CODE ###

def solve(x, y, d, m):
    ret = ""
    for i in range(m):
        if x + y >= 0 and x - y >= 0:
            ret += "R"
            x -= d[i]
        elif x + y >= 0 and x - y < 0:
            ret += "U"
            y -= d[i];
        elif x + y < 0 and x - y >= 0:
            ret += "D"
            y += d[i];
        else:
            ret += "L"
            x += d[i]
    print (ret)


def main():
    m = 34
    X, Y, d = [], [], []

    for i in range(32, 0, -1):
        d += [2**i]
    d += [1]

    N = int(input())
    even, odd = 0, 0

    for i in range(N):
        x, y = map(int, input().split())
        X += [x]; Y += [y]
    
        if (abs(x) + abs(y)) % 2 == 0:
            even += 1
        else:
            odd += 1

    if even and odd:
        print(-1)
        return 0

    if odd:
        m -= 1
    else:
        d += [1]

    print(m)
    print(" ".join(map(str, d)))

    for i in range(N):
        solve(X[i], Y[i], d, m)

main()
a,b=map(int,input().split())
if a>=13:
  print(b)
elif 6<=a<=12:
  pritn(b//2)
else:
  print(0)

### FIXED CODE ###

a,b=map(int,input().split())
if a>=13:
  print(b)
if a>=6 and a<=12:
  print(b//2)
if a<=5:
  print(0)
import sys
import numpy as np
import math

#input = sys.stdin.readline


def solve():
    n, m, le = map(int, input().split())
    paths = np.zeros((n, n))
    for i in range(n):
        for j in range(n):
            if i != j:
                paths[i, j] = math.inf

    for _ in range(m):
        a, b, c = map(int, input().split())
        paths[a - 1, b - 1] = c
        paths[b - 1, a - 1] = c

    for i in range(n):
        for j in range(n):
            for k in range(n):
                paths[i, j] = min(paths[i, j], paths[i, k] + paths[k, j])

    refuels = np.array(paths, copy=True)
    for i in range(n):
        for j in range(n):
            refuels[i, j] = 1 if paths[i, j] < le else math.inf
            if i == j:
                refuels[i, j] = 0

    for i in range(n):
        for j in range(n):
            for k in range(n):
                refuels[i, j] = min(refuels[i, j], refuels[i, k] + refuels[k, j])

    q = int(input())
    for _ in range(q):
        s, t = map(int, input().split())
        print(int(refuels[s-1, t-1] - 1 if refuels[s-1, t-1] < math.inf else -1))


if __name__ == "__main__":
    solve()


### FIXED CODE ###


from scipy.sparse.csgraph import floyd_warshall
import numpy as np

N, M, L = map(int, input().split())
graph = np.full((N, N), 10 ** 10)
for _ in range(M):
    s, t, w = map(int, input().split())
    if w <= L:
        graph[s - 1][t - 1] = graph[t - 1][s - 1] = w
graph = floyd_warshall(graph, directed=False)
graph = floyd_warshall(graph <= L, directed=False)
graph[np.isinf(graph)] = 0

Q = int(input())
ans = []
for _ in range(Q):
    s, t = map(int, input().split())
    ans.append(int(graph[s - 1][t - 1]) - 1)
print(*ans, sep='\n')
%%time
def combinations(R, G, B, N):
    R, G, B, N = int(R), int(G), int(B), int(N)
    sorted_tuple = sorted((R, G, B), reverse=True)
    R = sorted_tuple[0]
    G = sorted_tuple[1]
    B = sorted_tuple[2]
    number_combos = 0
    
    for x in range(N + 1):
        N_modified_x = N - R * x
        for y in range(N_modified_x + 1):
            N_modified_y = N_modified_x - G * y
            for z in range(N_modified_y + 1):
                if B * z == N_modified_y:
                    number_combos += 1
    return number_combos

print(combinations(13, 1, 4, 3000))

### FIXED CODE ###

def combinations(R, G, B, N):
    R, G, B, N = int(R), int(G), int(B), int(N)
    sorted_tuple = sorted((R, G, B), reverse=True)
    R = sorted_tuple[0]
    G = sorted_tuple[1]
    B = sorted_tuple[2]
    number_combos = 0

    for x in range(N // R + 1):
        for y in range((N - R * x) // G + 1):
            if (N - R * x - G * y) % B == 0:
                number_combos += 1
        
    return number_combos

R, G, B, N = input().split(' ')
print(combinations(R, G, B, N))
Tiles=input()
N_len=len(Tiles)
if N_len == 1:
    print("0")
    exit
    
cur=Tiles[0]

change=0
for i in range(1, N_len):
    if cur is TilePuttern[i]:
        change+=1
        cur = "0" if Tiles[i] == 0 else "1"
    else:
        cur=Tiles[i]
        
change_reverse=0
cur=Tiles[N_len-1]
for i in reversed(range(1, N_len-1)):
    if cur is TilePuttern[i]:
        change_reverse+=1
        cur = "0" if Tiles[i] == 0 else "1"
    else:
        cur=Tiles[i]

print(change if change < change_reverse else change_reverse)

### FIXED CODE ###

Tiles=input()
N_len=len(Tiles)
if N_len == 1:
    print("0")
    exit()
    
cur=Tiles[0]

change=0
for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))

min_change = change


change_first=1
if Tiles[0] == "0":
    cur = "1"
else:
    cur = "0"

for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_first+=1
        if min_change <= change_first:
            break

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]
        
if min_change > change_first:
    min_change = change_first

        
change_reverse=0
cur=Tiles[N_len-1]
for i in reversed(range(0, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse+=1
        if min_change <= change_reverse:
            break


        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))
    
if min_change > change_reverse:
    min_change = change_reverse


change_reverse_first=1
if Tiles[N_len-1] == "0":
    cur = "1"
else:
    cur = "0"

for i in reversed(range(0, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse_first+=1
        if min_change <= change_reverse_first:
            break

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

if min_change > change_reverse_first:
    min_change = change_reverse_first

print(str(min_change))
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, x = na()
bg = "P"
an = 2 ** (n+2) - 3
bn = 2 ** (n+1) - 1
if an > x:
    print(bn)
else:
    for i in range(n - 1):
        bg = "B" + bg + "P" + bg + "B"
        if len(bg) > x:
            bg = bg[:x]
    print(bg[:x].count("P"))

### FIXED CODE ###

import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + a[n-1]:
        return f(n-1, x-1)
    else:
        return p[n-1] + 1 + f(n-1, x-2-a[n-1])

print(f(n,x))