Creating algorithm to count cards