Now second material calculates Position X and Position Y from number you give it:
And now hard part for me: creating proper 4x4 flipbook texture with numbers