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 LstA As New List(Of Integer)
        For Each BookA As Integer In A
            LstA.Add(BookA)
        Next

        Dim LstB As New List(Of Integer)
        For Each BookB As Integer In B
            LstB.Add(BookB)
        Next

        Dim t As Integer = NMK(2)
        Dim ans As Integer = 0
        Do Until t <= 0
            If LstA.Count > 0 Then
                If LstB.Count > 0 Then
                    If LstA(0) <= LstB(0) Then
                        Call TryReadBook(t, LstA, ans)
                    Else
                        Call TryReadBook(t, LstB, ans)
                    End If
                Else
                    Call TryReadBook(t, LstA, ans)
                End If
            Else
                If LstB.Count > 0 Then
                    Call TryReadBook(t, LstB, ans)
                Else
                    Exit Do
                End If
            End If
        Loop

        Console.WriteLine(ans)

    End Sub

    Private Sub TryReadBook(ByRef t As Integer, ByRef lst As List(Of Integer), ByRef cnt As Integer)
        t -= lst(0)
        lst.RemoveAt(0)
        If t >= 0 Then
            cnt += 1
        End If
    End Sub

End Module
