Imports System

Module Program
    Sub Main(args As String())

        Dim NMK() As Integer = Console.ReadLine().Split(" ").Select(Function(x) Integer.Parse(x)).ToArray()
        Dim A() As Integer = Console.ReadLine().Split(" ").Select(Function(x) Integer.Parse(x)).ToArray()
        Dim B() As Integer = Console.ReadLine().Split(" ").Select(Function(x) Integer.Parse(x)).ToArray()

        Dim ReadB(NMK(1)) As Long
        ReadB(0) = 0
        For i As Integer = 0 To NMK(1) - 1
            ReadB(i + 1) = ReadB(i) + B(i)
        Next

        Dim ans As Integer = 0

        Dim t As Integer = NMK(2)
        Dim iB As Integer = NMK(1)
        For i As Integer = 0 To NMK(0)
            If i <> 0 Then
                t -= A(i - 1)
            End If
            If t <= 0 Then Exit For
            Dim readbook As Integer = i
            For j As Integer = iB To 0 Step -1
                If ReadB(j) <= t Then
                    readbook += j
                    iB = j
                    Exit For
                End If
            Next
            If ans < readbook Then
                ans = readbook
            End If
        Next

        Console.WriteLine(ans)

    End Sub

End Module
