for ( each word in M ) /* only significant word in M */
if ( word is in keyword list database )
if ( flag is equal to 3 )
keyword_count [word][ham] --; keyword_count [word][spam] ++;
else keyword_count [word][flag]++;
else add_keyword( word, flag )
if ( flag equal to 3 ) /* correct the count */
ham_count --; spam_count --;
else if ( flag equal to 1 )
ham_count ++; total_count ++;
else
spam_count ++; total_count ++;