Module Module1
    Sub main()
        Dim userInput As Object
        Dim total As Long
        Const MAXTIME As Long = 200001

        ' データの入力
        userInput = Split(Console.ReadLine())

        Dim nMax = userInput(0)
        Dim mMax = userInput(1)
        Dim kTime = userInput(2)

        Dim nStacks() As Object = Split(Console.ReadLine())
        Dim mStacks() As Object = Split(Console.ReadLine())
        ' 末端にダミー要素を追加
        'ReDim Preserve nStacks(UBound(nStacks) + 1)
        'nStacks(UBound(nStacks) + 1) = MAXTIME
        'ReDim Preserve mStacks(UBound(mStacks) + 1)
        'mStacks(UBound(mStacks) + 1) = MAXTIME

        Array.Resize(nStacks, nMax + 1)
        Array.Resize(mStacks, mMax + 1)
        nStacks(nMax) = MAXTIME
        mStacks(mMax) = MAXTIME

        Dim nNow = 0
        Dim mNow = 0
        Dim nPic = 0, mPic = 0

        Do
            ' 上から本を取得する
            'If nMax > nNow Then
            '    nPic = nStacks(nNow)
            'End If
            'If mMax > mNow Then
            '    mPic = mStacks(mNow)
            'End If

            nPic = nStacks(nNow)
            mPic = mStacks(mNow)

            'Console.WriteLine(nPic & ", " & mPic & ", " & kTime)

            If nPic < mPic And nPic <= kTime Then
                kTime -= nPic
                nNow += 1
            ElseIf mPic < MAXTIME And mPic <= kTime Then
                kTime -= mPic
                mNow += 1
            Else
                ' 両方の本が無くなった or 時間切れ
                Exit Do
            End If
            total = total + 1
        Loop

        '' 処理結果を返す
        Console.WriteLine(total)
    End Sub
End Module