auto generate ID

Using 'awk' i want to generate new ID..which should be increment of maximum number given as UID..
eg..in /etc/passwd..3rd field is UID..and we just want next user ID for this file..keep in mind that file is not sorted..so last line in the file may not display last UID..means UIDs in file are random..so we have to figure out maximum userID from file..

awk -F: '$3 > X {X = $3} END { print X+1 }' /etc/passwd

(use printf instead of print if you have a very large uid)