How to count the number of files and folders in iCloud Drive?
Using the macOS Terminal Application

First change the current directory to the root of the iCloud drive by entering the command given below.

cd ~/Library/Mobile\ Documents/com\~apple\~CloudDocs


Next, enter one or more of the commands given below.

List of folders and files

 find . -name "*"


List of files

 find . -name "*" -type f


List of folders

 find . -name "*" -type d


Count of folders and files

 find . -name "*" | wc -l


Count of files

 find . -name "*" -type f | wc -l


Count of folders

 find . -name "*" -type d | wc -l


To get a list of all files and folders sorted in lexicographical order, enter the following command.

ls -RlAa


Since the folders . and .. occur in each folder, you may wish to omit these folders by using the command given below.

ls -RlA


Using the Windows Command Prompt Window

First change the current directory to the root of the iCloud drive by entering the command given below.

cd /d %userprofile%\iCloudDrive


Next, enter one or more of the commands given below. 

List of files

 dir /s /b


List of folders

 dir /s /b /a:d


Count of files

 dir /s /b | find /v "" /c


Count of folders

 dir /s /b /a:d | find /v "" /c


To get a list of all files and folders sorted in lexicographical order, enter the following command.

dir /s


Notes


iCloud is implemented differently on Windows and macOS operating systems. Some folders and files will appear in one operating system but not in the other. 
The files and folders displayed may differ between the operating systems. I have found with macOS, some file names also differ between what is displayed by the Finder application and the Terminal application.
The counts of the files and folders in a folder may differ between the operating systems.
The lexicographical order is handled differently by Windows and macOS. Windows is case-independent and macOS is case-dependent.