Author final version of On groups and counter automata