Imports System

Module Program
    Sub Main(args As String())

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

        Dim ans As Long = 0
        Dim ReadCount As Long = 0
        Dim tA As Long = NMK(2)
        Dim rA As Long = 0
        For iA As Long = 0 To NMK(0) - 1
            tA -= A(iA)
            If tA >= 0 Then
                rA += 1
                Dim tB As Long = tA
                Dim rB As Long = rA
                For iB As Long = 0 To NMK(1) - 1
                    tB -= B(iB)
                    If tB >= 0 Then
                        rB += 1
                    Else
                        Exit For
                    End If
                Next
                If ans < rB Then
                    ans = rB
                End If
            Else
                Exit For
            End If
        Next

        Console.WriteLine(ans)

    End Sub

End Module
