let input = readLine()!.split(separator: " ")
let N = Int(input[0])!
let M = Int(input[1])!
var K = Int(input[2])!

let A = readLine()!.split(separator: " ").map { Int($0)! }
let B = readLine()!.split(separator: " ").map { Int($0)! }

var dp: [[Int]] = .init(repeating: .init(repeating: -1, count: B.count + 1), count: A.count + 1) 

func dfs(_ A: [Int], _ B: [Int], _ a: Int, _ b: Int, _ K: Int) -> Int {
  
  if a >= A.count && b >= B.count {
    return 0
  }
  if K <= 0 {
    return 0
  }
 
  if dp[a][b] != -1 {
    return dp[a][b]
  }
  
  var takeA = a < A.count && K - A[a] >= 0 ? dfs(A, B, a + 1, b, K - A[a]) + 1 : 0
  var takeB = b < B.count && K - B[b] >= 0 ? dfs(A, B, a, b + 1, K - B[b]) + 1 : 0
  dp[a][b] = max(takeA, takeB)
  
  return dp[a][b]
  
}

print(dfs(A, B, 0, 0, K))