read n m k
read -a a
read -a b
c=0
a+=(999999999999)
b+=(999999999999)
am=0
ai=0
bm=0
bi=0
for x in ${a[@]}
do
    if((am+x>k))
    then
        break
    else
        am=$((am+x))
        ai=$((ai+1))
    fi
done
for x in ${b[@]}
do
    if((bm+x>k))
    then
        break
    else
        bm=$((bm+x))
        bi=$((bi+1))
    fi
done
for x in ${b[@]}
do
    if((am+x>k))
    then
        break
    else
        am=$((am+x))
        ai=$((ai+1))
    fi
done
for x in ${a[@]}
do
    if((bm+x>k))
    then
        break
    else
        bm=$((bm+x))
        bi=$((bi+1))
    fi
done
echo $((ai>bi?ai:bi))