We define an integer invariant [Formula: see text] of a smooth, compact, closed 4-manifold X by minimizing a certain complexity of a trisection of X over all trisections. The good feature of [Formula: see text] is that when [Formula: see text] and X is a homology 4-sphere, then X is diffeomorphic to the 4-sphere. Naturally, L is hard to compute.