adding dima's counting algorithm. right now it outputs a pickled file, but I'm thinking json might actually be better to speed up writing/reading the file