import ast


def countVariables(a, id):
	"""Count the number of times the given variable appears in the AST"""
	if type(a) == list:
		return sum([countVariables(x, id) for x in a])
	if not isinstance(a, ast.AST):
		return 0

	count = 0
	for node in ast.walk(a):
		if type(node) == ast.Name and node.id == id:
			count += 1
	return count