Module Module1
    Sub main()
        Dim userInput As Object
        Dim total As Long

        ' データの入力
        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())

        Dim nNow = 0
        Dim mNow = 0
        Dim nPic = 200001
        Dim mPic = 200001

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

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

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


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