How to use prepare to query with variables

Try adding the single quotes back around the %s:

$countthem = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM wp_cmapg WHERE lang='%s'", $lang) );