import collections


def count_kmers(k, seq):
    """Return a map from kmer of size `k` to count in `seq`"""
    result = collections.defaultdict(int)
    for i in range(0, 1+len(seq)-k):
        result[seq[i:i+k]] += 1
    return result