Simple key signature detection algorithm