peterverebics/CodeNet_Python_118 huggingface dataset:
a=input()
b=input()

if a==b[:-1]:
	print("yes")
else:
	print("No")
S = input()
T = input()
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')
import sys

S = sys.stdin.readline().rstrip()
T = sys.stdin.readline().rstrip()

if S[:-1] == T:
    print('Yes')
else:
    print("No")
n =str(input())
r =str(input())
s = len(n)
t = len(r)
if  n== r[0:t] and s+1==t and 1<=s<=10:
    print('Yes')
else :
    print('No')
s = input()
t = input()

if (s is t[:-1]) and (len(s) + 1 is (len(t))):
    print('Yes')
else:
    print('No')
s = str(input())
t = str(input())

if s <= t :
    print('Yes')
else:
    print('No')
a = input()
print(a)
b = input()
print(b)

a_len = len(a)
b_r = b[:-1]

print(b_r)

if b_r == a and a_len <= 10 and a_len >= 1:
 	print("Yes")
else:
	print("No")
s = input()
t = input()

if s in t:
    if len(s) <len(t):
        print('Yes')
    else:
        print('No')
else:
    print('No')
a = input()
b = input()
if a in b:
    print('Yes')
else:
    print('No')
S = input()
T = input()
if S == T[:-1]:
    print('Yes')
else:
    print('NO')
lS=list(input())
T=input()

lT=list(T)
lT.remove(T[len(T)-1])

if lS==lT:
  print('Yes')

else:
  print('No')
s = input()
t = input()
if len(t)-1 == len(s) and len(s) < 10:
  if t.islower() == True:
  	print('Yes' if s[0:-1] == t[0:-2] else 'No')
  else:
    print('No')
else:
  print('No')
a = input()
b = input()
b = b[0:len(b)-1]
#print(b)
print(a==b)
s = input()
t = input()

abc = 'abcdefghijklmnopqrstuvwxyz'
ans = 'No'
if 1 <= len(s) <= 10 and len(t) == len(s) + 1 and all([c in abc for c in t]):
    ans = 'Yes'

print(ans)
S=input()
T=input()
if S==T[:len(T)]:
  print("Yes")
else:
  print('No')
S = input()
T = input()
if T[0:len(S)] == S and len(S) + 1 == len(T):
    print('Yes')

print('No')
S=input()
T=input()
A=S+T
if T.rstrip() != S:
  print("No")
elif len(T)-len(S)!=1:
  print("No")
elif len(S)<= 0 or len(S)>= 11:
  print("No")
elif  A.isalpha() and A.islower():
  print("Yes")
else:
  print("No")
s = input().strip()
t = input().strip()
print(s == t[:-1])
S = input()
T = input()
print('Yes' if len(T.replace(S, ''))==1 and len(T) - len(S) == 1 else 'No')
S = input()
T = input()
 
if S == T[:-1]:
     print("YES")
else:
     print("NO")
s = input()
t = input()
Y = True
if len(t) != len(s)+1:
  Y = False
  print('No')
for i in range(len(s)):
  if s[i]!=t[i]:
    Y = False
    print('No')
if Y:
  print('Yes')
x = input()
y = input()

if x == y[::-1]:
	print('Yes')
else:
	print('No')
#import collections
# c = collections.Counter()
#import itertools as it
#import math
#import numpy as np
#import sys 
#sys.exit()
 
s = input()
t = input()
#k = int(input())
#a, b  = map(int, input().split())
'''
#  = list(map(int, input().split()))
'''
'''
n = input()
a = [int(input()) for i in range(n)]
'''
'''
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
'''
 
#-------------------------------#
 
if len(t)==len(s)+1 and 0<len(s)<=10:
	print('Yes')
else:
  	print('No')
s = input()
t = input()
if t[:-1] == s:
  print('Yes')
else:
  print('NO')
import re
s=str(input())
t=str(input())
t2=re.sub(r'^[a-z]*',"",t)
if len(t2)==1 and re.sub(r"[a-z]","",t2)=="":
  print("Yes")
else:
  print("No")
s = input()
t = input()
t = t[:-1]

flag = 0
for i in range(len(t)-1):
    if s[i] is not t[i]:
        flag = 1
        break
if flag is 0 :
    print("Yes")
else:
    print("No")
bef = str(input())
aft = str(input())


print(("No","Yes")[len(aft[0:len(bef)].strip(bef) + aft[len(bef):]) == 1])
import re
S = input()
T = input()
T = T.replace(S,'',1)
beforeT = T
T = re.sub('[a-z]','',T,1)
if beforeT == T:
    print("No")
    exit(0)
if T == "":
    print('Yes')
else:
    print('No')
S = input()
T = input()
T1 = T[:-1]
if S == T:
  print("Yes")
else:
  print("No")
s = input()
t = input()

def main():
    if len(s) <= 1 and len(s) >=10:
        print('No')
        return

    if (s.isalpha() == False or s.islower() == False):
        print('No')
        return

    if (t[-1].isalpha() == False or t[-1].islower() == False):
        print('No')
        return

    if len(t) == len(s) + 1 and t[:-2] == s[:-1]:
        print('Yes')
    else:
        print('No')
    return

main()
s=input()
f=0
s1=input()
for i in range(0,len(s)):
    if s[i]==s1[i]:
        f=1
    else:
        f=0
        break
if f==0:
    print("NO")
else:
    print("YES")
S = str(input())
T = str(input())

if S == T:
    print("Yes")
else:
    print("No")
S = input()
T = input()
 
if len(T)-len(S) == 1:
  print('Yes')
else:
  print('No')
def is_ID(S, T):
    if 1<=len(S)<=10:
        if S.islower() and S.islower():
            if S==T[:-1]:
                return(print("Yes"))

    return(print("No"))

is_ID("abc","abcV")
s=str(input()) #　a1
t=str(input()) #　a1


if len(t.replace(s,'',1))==1:
  print('Yes')
else:
  print('No')
def task(s, t):
    if s <= t:
        print("Yes")
    else:
        print("No")


s = input()
t = input()
task(s, t)
s, t = open(0).read().split()

if len(t) == len(s) + 1 and s == s.lower():
    print("Yes")
else:
    print("No")
s = input()
t = input()
if 1<=len(s) and len(s)<=10 and len(s)+1==len(t):
  print('Yes')
else:
  print('No')
s = input()
t = input()

if len(s)+1 == len(t)+1:
    print("Yes")
else:
    print("No")
s=input()
t=input()
print('Yes'if t.count(s)>=1 else'No')
S = input()
T = input()

Slis = list(S)
Tlis = list(T)
Tlis.remove(Tlis[ - 1])
if Slis  == Tlis:
    print('Yes')
else:
     print('No')
s = len(input())
t = len(input())

if s+1 == t:
    print("Yes")
else:
    print("No")
S=str(input())
T=str(input())
z=0
if S in T:
    if T[-1].islower():
        if T[-1].isalpha():
            z+=1
            print("Yes")
            
if z==0:
    print("No")
S=input()
T=input()
if(S==T):
  print("No")
elif(S==T[:-1]):
  print("Yse")
else:
  print("No")
s = input()
t = input()
if len(s)+1 == len(t):
  print('Yes')
else:
  print('No')
s, t = open(0).read().split()

if len(s) >= 1 and len(s) <= 10 and len(t) == len(s) + 1 and s == s.lower():
    print("Yes")
else:
    print("No")
S = input()
T = input()

if len(T) == 2 and T[0] == T[1]:
    print("YES")
else:
    T = T.replace(S,"")
    if len(T)==1 and T.islower()==True:
        print("YES")
    else:
        print("NO")
s=input()
t=input()
le=len(t)
l=len(s)
count=0
ans='none'
n_s=t[:l]
if l==le:
    ans='no'
else:
    if s==n_s:
            ans='yes'
    else:
        ans='no'
       
print(ans)
n = str(input())
t = str(input())
N = list(n)
T = list(t)
del N[-1]
if N == T:
    print("Yes")
else:
    print("No")
s = input()
t = input()

abc = 'abcdefghijklmnopqrstuvwxyz'
ans = 'No'
if 1 <= len(s) <= 10 and len(t) == len(s) + 1 and all([(c in abc) for c in t]):
    ans = 'Yes'

print(ans)
S = input()
T = input()

if S in T and len(T)-len(S) == 1:
    print("Yes")
else:
    print("No")
#problemA
S = input()
T = input()
print(T)
d = T[-1]
U = T.rstrip(d)
if (U == S) and (len(T) - 1 == len(S)):
    print("Yes")
else:
    print("No")
S=input()
T=input()


if len(S)+1==len(T):
    for i in range(len(S)): #回数の時は絶対range()
        if S[i]==T[i]:
            a='ok'
            continue
        else:
            a='no'
            break
else:
    print('no')

if a=='ok':
    print('yes')
else:
    print('no')
s = input()
t = input()
if s == t[:-1]:
    print("YES")
else: 
    print("NO")
n =str(input())
r =str(input())
if  'n' in  r  :
    print('Yes')
else :
    print('No')
S=input("")
T=input("")
l=len(S)
if S==T[:-1] and S.islower()==True and 1<=l and l<=10:
  print("Yes")
else:
  print("NO")
s = input()
t = input()
 
if s == t[:-1]:
     print("YES")
else:
     print("NO")
originalName = input()
modifiedName = input()
if originalName in modifiedName and len(modifiedName) == len(originalName) + 1:
    print('Yes')
else:
    print('No')
S=input()
T=input()
if(T[0:len(S)-1]==S):
  if(len(S)==len(T)-1):
  	print("Yes")
  else:
    print("No")
else:
  print("No")
s = input()

t = input()

if s.isalpha() == True & t.isalpha() == True:
    if s.islower() == True & t.islower() == True:
        if 1 <= len(s) <= 10:
            if len(t) == len(s) + 1:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')
import re
s = input()
t = input()

if len(re.sub(s, '', t)) == 1:
    print('Yes')
else:
    print('No')
a = str(input())
b = str(input())
if a == "chokudai" and b == "chokudaiz" or a == "a" and b == "aa":
    print("Yes")
elif a == "snuke" and b == "snukee":
    print("No")
s=input()
t=input()

sl=len(s)
tl=len(t)
if sl+1==tl:
    print("Yes")
else :
    print("No")
s = str(input()).lower()
t = str(input()).lower()
if s in t and len(t) == len(s) + 1 :
    print('Yes')
else:
    print('No')
s = input()
t = input()

if t[:-1] == s:
	print('yes')
else:
	print('no')
from sys import stdin

S = list(stdin.readline().rstrip())
T = list(stdin.readline().rstrip())

S[:len(S)]
T[:len(S)]

if S == T:
    print('Yes')
else:
    print('No')
def resolve():
    s = str(input())
    t = str(input())
    if t[:len(s)] == s and len(t[len(s):]) == 1 and len(t) <= 10:
        print('Yes')

    else:
        print('No')


resolve()
s = input()
t = input()
 
if s in t:
  print('Yes')
else:
  print('No')
s = input()
t = input()
if len(t) == len(s)+1:
  if t.islower() == True:
  	print('Yes' if s[0:-1] == t[0:-2] else 'No')
  else:
    print('No')
else:
  print('No')
A = input()
B = input()

if (A in B) and (len(B)-len(A)==1):
  print("Yes")
else:
  print("No")
S=str(input())
T=str(input())
co=0
cou=0
for i in S:
    co+=1
for j in T:
    cou+=1
if cou-co==1:
    print("Yes")
else:
    print("No")
s=input()
r=input()
c=0
for i in range(len(s)):
    if(s[i]==r[i]):
        c=c+1
if(c==len(s) and len(r)==len(s)+1):
    print("YES")
else:
    print("NO")
S = input()
T = input()
if T.rfind(S) != -1:
  print('Yes')
else:
  print('No')
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce
import bisect

MOD = 10**9 + 7
INF = float('inf')

S = input()
T = input()
print(S)
print("YNeos"[(T[:-1] != S)::2])
a,b=open(0);print("YNeos"[a[:-2]!=b[:-2]::2])
S=input()
T=input()
if len(S)==1:
	if S[0]==T[0]:
		print("YES")
	else:
		print("NO")
elif len(S)>=2:
	if S in T:
		if S[0]==T[0] and S[1]==T[1]:
			print("YES")
		else:
			print("NO")
	else:
		print("NO")
s=input()
t=input()
z= t[0:len(t)-1]
p = t[1:len(t)]
if(s==z or s==p):
    print("Yes")
else :
    print("No")
from sys import stdin,stdout
s = stdin.readline()
t = stdin.readline()
n = len(s)
no = False
for i in range(n):
  if s[i] != t[i]:
    no = True
    break
if no:
  print("No")
else:
  print("Yes")
s = input()
t = input()
if s in t and len(t) == len(s)+1 :
    print('Yes')
else :
    print('No')
S=input()
T=input()
if T.find(S)==-1:
    print('no')
else:
    print('yes')
s, t = open(0).read().split()

if len(t) == len(s) + 1 and t == t.lower():
    print("Yes")
else:
    print("No")
# coding: utf-8
s1 = input()
s2 = input()
s2 = s2.strip(s2[-1])

if s1 == s2:
    print("Yes")
else:
    print("No")
s=input()
t=input()
if s[0:-1]==t[0:-2]:
    print("Yes")
else:
    print("No")
def main():
    s = input()
    t = input()
    r = t.replace(s,"")
    if len(r) == 1:
        print("Yes")
        return
    else:
        print("No")
        return
main()
s=input()
t=input()
if s in t:
  if len(s)+1==len(t):
    print('Yes')
else:
  print('No')
a = input()
b = input()

if a in b and (len(a) + 1) == len(b) and b.islower() and a.islower() and len(a) >= 1 and len(a) <= 10:
  print("Yes")
else:
  print("No")
if __name__ == '__main__':
    a=input()
    b=input()
    if len(b)-len(a)==1:
        if b.find(a) !=-1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
s = input()
t = input()
if len(s)+1 == len(t) and s == t[:-2]:
  print("Yes")
else:
  print("No")
s = input()
t = input()
if s == t[0:-1]:
    print('Yes')
else:
    print('NO')
S = input()
T = input()
abc = 'abcdefghijklmnopqrstuvwxyz'

if S == T[:-1] and T[-1] in abc:
    print('yes')
else:
    print('no')
S=input()
T=input()
if S==T[:-2]:
  print("Yes")
else:
  print('No')
S = input()
T = input()
condition = True
for i in range(len(S)):
  if S[i] !=T[i]:
    condition = False
if condition:
  print("YES")
else:
  print("NO")
s = input()
t = input()
 
if (s in t) and (t[:1] == s):
    print("Yes")
else:
    print("No")
def main():
    s = str(input())
    t = str(input())
    if s in t and len(s) + 1 == len(t):
        print('Yes')
    else:
        print('No')


def input_list():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()
a,b,c,k = map(int,input().split())

if k <= a+b:
    print(min(k,a))
else:
    print(a-(k - (a+b)))
# coding:utf-8
a, b, c, k = map(int, input().split())
point = 0

if k <= a:
    point += k
elif k > a and (k - a) <= b:
    point += a
elif k > a and (k - a) > b:
    point = a + (-1) * (k - a - b)

print(point)
a,b,c,k=map(int,input().split())
ct=k
result = 0
if a>0:
  if ct>a:
    result=1*a
  elif a>=ct:
    result=1*ct
  ct=k-a
if ct>0 and b>0:
  ct=ct-b
if ct>0 and c>0:
  result=result+(-1*ct)
print(result)
# -*- coding: utf-8 -*-
 
a = list(map(int,input().split()))

A, B, C, K = a[0], a[1], a[2], a[3]

if ( K <= A ):
  print(K)
elif ( K <= A+B ):
  print(A)
elif ( K <= A+B+C ):
  print(2*A+B-K)
else:
  print(A-C)
a, b, c, k = map(int, input().split())

if a >= k:
    print(k)
    exit()

if k-a-b <= 0:
    print(a)
    exit()

print(a-(k-a-b))
a,b,c,k=map(int,input().split())
if a>=k:
  print(k)
elif a+b>=k:
  print(a)
else:
  print(2*a+b-k)
a, b, c, k = map(int, input().split())
d = k - a - b

if k < a:
	print(k)

elif a <= k <= a + b:
	print(a)

elif a + b < k <= a + b + c:
	print(a - d)
a, b, c, k = map(int, input().split())

if k<=a:
	ans = k
elif k<=a+b:
	ans = a
else:
	ans = a-(k-a-b)

print(ans)
a, b, c, k = list(map(int, input().split()))

c = k- a- b

if c < 0 :
    c = 0
if a > k:
    a = k


print(a -c)
a, b, c, k = map(int, input().strip().split())

d = 0

if a > k:
  d += k
else:
  d += a
  k -= a
  if b > k:
    d += 0
  else:
    d += 0
    k -= b
    d -= k

print(d)
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    A, B, C, K = map(int, input().split())

    ans = 0
    if A >= K:
        print(K)
        exit()
    ans += A
    K -= A
    if B >= K:
        print(ans)
        exit()
    K -= B
    if C >= K:
        ans -= K
    else:
        ans -= C
    print(ans)

if __name__ == '__main__':
    main()
A, B, C, K = map(int, input().split())

if K <= A:
    print(K)
elif A < K <= A + B:
    print(A)
else:
    print(A - (K - A - B))
a, b, c, k = map(int, input().split())

if a >= k:
  a = k
  b = 0
  c = 0
if a < k and a+b >= k:
  c = 0
if a+b < k:
  c = k - a - b
  
sum_a = 1 * a
sum_c = -1 * c
  
print(sum_a + sum_c)
import sys

A, B, C, K = map(int, input().split())
if A >= K:
    print(K)
elif A + B >= K:
    print(A)
else:
    print(A + (A+B-K))
s = input()
A, B, C, K = [int(v) for v in s.split(" ")]

if K <= A:
  print(K)
elif K <= A + B:
  print(A)
elif K <= A + B + C:
  print(A - (K - A - B))
#--Easy Linear Programming

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

number = 0
count = 0
if (k <= a):
    count = count + k
    print(count)
    exit()

if (k > a):
    number = number + a
    count = count + a

kk = k - number

if (kk <= b):
    print(count)
    exit()

if (kk > b):
    number = number + b

kkk = k - number

if (kkk <= c):
    count = count - kkk
    print(count)
    exit()

if (kkk > c):
    count = count - c

print(count)
a, b, c, k = map(int, input().split())

if k <= a:
    print(k)
elif k <= (a + b):
    print(a)
else:
    print(a - (k - a - b))
a, b, c, k = map( int, input().split())

if k <= a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(a-(k-a-b))
a, b, c, k = map(int, input().split())

if a >= k:
    print(k)
elif a + b >= k:
    print(a)
else:
    print(a - (k -(a+b)))
a, b, c, k = list(map(int, input().split()))
print(min(a, k) - max((k - (a + b), 0)))
A, B, C, K = map(int, input().split())
print(min(K, A)-max(0, K-A-B))
def main():
    a, b, c, k = map(int, input().split())
    res = 0

    res += 1 * min(a, k)
    k -= a
    if k > 0:
        k -= b
    if k > 0:
        res += (-1 * min(c, k))
    print(res)

if __name__ == '__main__':
    main()
z = input().split()
a=int(z[0])
b=int(z[1])
c=int(z[2])
k=int(z[3])
res=0

if k>=a:
 res=res+a
 if k-1>=b:
   res=res+b-b
   if k-(a+b)>=c:
    res=res+c-2*c
   else:
    res=res+(k-a-b)-2*(k-a-b)
 else:
   res=res+(k-a)-(k-a)
else:
 res=res+k
print(res)
# 初期入力
import sys
input = sys.stdin.readline
A,B,C,K = list(map(int, input().split()))
a=1
b=0
c=-1
count =K
point =0
if A< K:
    point +=A
    count -=A
    K -=A
else:
    point +=K
    count =0
    print(point)
    exit()

if B < count:
    point +=0
    count -=B
    K -=B
else:
    point +=0
    count =0
    print(point)
    exit()    

if C <= count:
    point -=C
else:
    point -=count
    count =0
    
print(point)
a, b, c, k = map(int, input().strip().split())


def solve():
    global k

    total = 0
    num_a = min(k, a)

    total += num_a

    k -= num_a

    if k <= 0:
        return total

    num_b = min(k, b)

    if k <= 0:
        return total

    k -= num_b

    num_c = k
    total -= num_c

    return total

print(solve())
a, b, c, k = list(map(int, input().split()))
if k <= a:
	s = k * 1
elif k <= (a+b):
	s = a * 1
else:
	s = (a * 1) + ((k-(a+b)) * (-1))
print(s)
string = input()
array = string.split(' ')
a = int(array[0])
b = int(array[1])
c = int(array[2])
k = int(array[3])

answer = 0
if a >= k:
  answer = k
else:
  answer = a
  if b >= k - a:
    answer += 0
  else:
    answer -= k - a - b
print(answer)
A, B, C, K = list(map(int,input().split()))
count = 0
s = 0
if A > K:
	print(K)
elif A+B > K:
	print(A)
else:
	print(2*A + B - K)
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b,c,K = IL()

if K <= a:
  print(K)
elif a < K <= a+b:
  print(a)
else:
  print(a - (K - (a+b)))
a,b,c,k = map(int, input().split())

if a >= k:
    print(k)
else:
    print(a-(k-a-b))
a, b, c, k =map(int, input().split())  #複数数値入力

if a+b >= k:
    if a < k :
        print(a)
    else:
        print(k)
else:
    print(a-(k-a-b))
a, b, c, k = map(int, input().split())
if k < a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(a-(k-a-b))
A, B, C, K = map(int, input().split())

backup = K
AB = A + B
flag = False
ans = 0
if K <= A:
    print(K)
else:
    if A < K:
        K = K - A
        ans = ans + (A * 1)
    if B <= K:
        K = K - B
        flag = True
    if K > 0 and flag:
        ans = ans + (-1) * (backup - AB)
    print(ans)
A,B,C,K = map(int,input().split())

if K<=A:
  print(K)
elif K<=A+B:
  print(A)
elif K<=A+B+C:
  print(A-(K-B-A))
else:
  print(A-C)
A,B,C,K = map(int,input().split())

if A+B<K:
  print(A-(K-A-B))
else:
  print(min(A, K))
A, B, C, K = [int(_) for _ in input().split()]

l = A + B + C - K

def solve(A, B, C, K):
    result = 0
    n = min(A, K)
    result += n
    K -= n
    A -= n
    if K == 0:
        return result
    n = min(B, K)
    K -= n
    B -= n
    if K == 0:
        return result
    n = min(C, K)
    result -= n
    K -= n
    C -= n
    return result

print(solve(A, B, C, K))
def main():
    from builtins import int, map, list, print, min
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A,B,C,K = input_number_list()
    ans = min(A,K)
    K -= A+B
    if K>0:
        ans -= min(C,K)
    print(ans)


if __name__ == '__main__':
    main()
#ABC167-B
a,b,c,k=map(int,input().split())
if a>k:
  print(k)
elif a+b>=k>=a:
  print(a)
else:
  print(a+(a+b-k))
a, b, c, k = map(int,input().split())

if a >= k:
    print(k)
elif a < k and a+b >= k:
    print(a)
elif a+b < k:
    print(a-(k-a-b))
a,b,c,k = (int(x) for x in input().split())
import sys 

if a >= k:
    print(k * 1)
    sys.exit()
elif k > a:
    if a + b >= k:
        print(a * 1)
        sys.exit()
    elif k > a + b:
        print(a * 1 + (k - a - b)* -1)
        sys.exit()
a,b,c,k=map(int,input().split())
if k<=a:
  ans=k
elif k>a and k<=a+b:
  ans=a
else:
  ans=a-(k-(a+b))
print(ans)
a,b,c,k = [int(x) for x in input().split()]
ans = 0
ans += min(a,k)
k = k-a-b
if k>=0:
    ans -= k
print(ans)
A,B,C,K = list(map(int,input().split()))

if A>=K:
    print(K)
elif A+B>=K:
    print(A)
else:
    print(A - (K-A-B))
nums = [int(e) for e in input().split()]

if nums[3] < nums[0]:
    M = nums[3]
elif nums[0] <= nums[3] <= nums[0] + nums[1]:
    M = nums[0]
elif nums[0] + nums[1] < nums[3]:
    M = nums[0] - (nums[3] - nums[0] - nums[1])

print(M)
def solve():
    a, b, c, k = map(int, input().split())
    if k > a + b:
        ans = a - (k - a - b)
        print(ans)
    else:
        print(min(k, a))


if __name__ == '__main__':
    solve()
A, B, C, K = list(map(int, input().split( )))
     
if(K < A):
      score = K
elif(K >= A and K <= A+B):
      score = A
else:
     score = A - (K - A - B)
     
print(score)
a, b, c, k = map(int, input().split())

ans = 0

ans += min(a, k) - min(c, max(0, k-a-b))

print(ans)
A,B,C,K = map(int, input().split())

if A >= K:
    print(K)
elif A + B >= K:
    print(A)
else:
    L = K - A - B
    print(A - L)
a,b,c,k = map(int,input().split())
if a >= k:
    print(k)
else:
    if a+b >= k:
        print(a)
    if a+b < k:
        d = k-a-b
        print(a-d)
a,b,c,k = map(int,input().split())


ka = k - a

if ka > 0:
    kb = ka - b
elif ka <= 0:
    a = k
    ka = 0
    kb = 0
else:
    kb = 0
print(a*1+ka*0+kb*-1)
import sys
a,b,c,k = [int(_) for _ in input().split()]

ans = 0
if a >= k: #
  print(k)
  sys.exit()
else:
  ans = a
  k = k -a

if k != 0 and k - b > 0:
  print(a-(k-b))
else:
  print(a)
A , B , C , K = map ( int  ,input().strip().split(" ") ) 
l = [ 1 , 0 , -1 ] ;
t = 0 

for ( c,r ) in zip ( l , ( A, B , C ) ) :

	if r >= K :
		t += K * c ;
		break ;
	else :
		K -= r ;
		t += r * c ;
print ( t ) ;
A, B, C, K = map(int, input().split())
if(A >= K): print(K)
elif(A + B >= K): print(A)
else: print(A - (K - (A + B)))
a, b, c, k = map(int, input().split())

if a >= k:
    print(k)
elif a < k <= a+b:
    print(a)
elif a+b < k <= a+b+c:
    print(a-(k-a-b))
a,b,c,k = map(int,input().split())
if k < a:
  print(k)
elif a <= k and k < a+b:
  print(a)
else:
  print(a-(k-a-b))
A,B,C,K=map(int,input().split())
if K<A:
  print(K)
if A<=K<A+B:
  print(A)
if A+B<=K:
  print(2*A+B-K)
if __name__ == '__main__':

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

    ans = 0
    if k >= a:
        k -= a
        ans += a
    else:
        ans += k
        print(ans)
        exit()
    
    if k >= b:
        k -= b
    else:
        print(ans)
        exit()
    
    if k >= c:
        ans += c * (-1)
    else:
        ans += k * (-1)

    print(ans)
a,s,c,k = map(int,input().split())
if a>=k:
  print(k)
elif a+s>=k:
  print(a)
else:
  print(a - (k-a-s))
A, B, C, K = map(int, input().split())

if K <= A:
  max = K

if A < K <= A + B:
  max = A

if A + B < K:
  max = A - (K - A - B)

print(max)
A, B, C, K = map(int, input().split())

ans = 0
a = min(A, K)
ans += a

K -= a
b = min(B, K)
K -= b

c = min(C, K)
ans -= c

print(ans)
from typing import NoReturn


def main() -> NoReturn:
    a, b, c, k = map(int, input().split())  # type: int, int, int, int
    if a >= k:
        print(k)
    elif a + b >= k:
        print(a)
    else:
        print(2 * a + b - k)


if __name__ == '__main__':
    main()
A,B,C,K = list(map(int, input().split()))

if(K<=A):
  print(K)
elif(K<=A+B):
  print(A)
else:
  print(A-(K-A-B))
a, b, c, k = map(int, input().split())

if a >= k:
    print(k)
elif a+b >= k:
    print(a)
elif a+b+c >=k:
    sum = a - (k - (a+b))
    print(sum)