All of the information about a PostgreSQL database's tables are stored in the database's pg_class table.
select count(*) from pg_class where relname='tablename' and relkind='r'
should therefore return the number of ordinary tables in that database named "tablename".
Assuming that the user making the query has SELECT privileges on that table.