Costum walker with sub menu item count

Inside the function your $x is local.

You might want to use a static variable:

class Walker_Nav_Menu_Costum extends Walker_Nav_Menu {
    static $x = 0;

    function end_el( &$output, $item, $depth = 0, $args = array() )
    {
        if ( 1 == $depth ) self::$x++;
        $output .= "<!-- x:".self::$x."-->";
        $output .= "</li>\n";
    }
}