4. In a certain country, there are 47 cities. Each city has a bus station from which buses run to other cities in the country and possibly abroad. A traveler studied the schedule and determined the number of internal bus routes departing from each city. It turned out that if the city of Lake is not considered, then for each of the remaining 46 cities, the number of internal routes departing from it differs from the number of routes departing from other cities. Find out how many cities in the country have direct bus connections with the city of Lake.

The number of internal bus routes for a given city is the number of cities in its own country that can be reached from the given city by a direct bus, without transfers. The routes are symmetric: if you can travel from city $A$ to city $B$, then you can also travel from city $B$ to city $A$.
Solution.

Note that external lines are not considered in this problem.

There are a total of 47 variants of the number of internal lines - from 0 to 46. Note that the existence of a city with 46 lines excludes the existence of a city with 0 lines and vice versa.

Suppose there is a city with 46 lines. Then the smallest number of lines leading out of one city is one, and all numbers from 1 to 46 are encountered without gaps (cities excluding Lake City - 46). The city with one bus line cannot be connected to Lake City, as its only line must lead to the city with 46 lines (otherwise, the 46th pair would not be found). We have organized the pair 1-46. Now consider the city with 45 lines. We will match it with the city with two lines. Note that the city with two lines cannot be connected to Lake City. Continuing this reasoning, we will organize pairs 3-44, 4-43, and so on, up to the pair 23-24. The city with the smaller number of lines in each pair is not connected to Lake City. Note that Lake City does not enter these pairs, as a connection with Lake City is necessary for a larger number of lines in each pair. Thus, all cities are divided into pairs, and each number of lines from 1 to 46 occurs exactly once. Since in each pair exactly one city is connected to Lake City, Lake City is connected to 23 cities, the number of pairs.

Suppose the maximum number of lines is 45. Then there is a city with 0 lines (buses from it go only abroad), and all numbers from 0 to 45 are encountered without gaps (cities excluding Lake City - 46). Again, we will form pairs 0-45, 1-44, and so on to 22-23. Similarly to the previous case, in the pair 0-45, the first city is not connected to Lake City, while the second is connected (otherwise, it would not be possible to get 45 lines from it). In the pair 1-44, the city with one line is not connected to Lake City (its connection is occupied by the line to the city with 44 lines), while the city with 44 lines is connected to Lake City to reach the required number of lines. Further, in the pair 2-43, the city with two lines is not connected to Lake City (its connection is occupied by lines to the cities with 44 and 43 lines), while the city with 43 lines is connected to Lake City to reach the required number of lines. We have 23 pairs. Lake City is connected to exactly one city in each pair, so it is connected to 23 cities.

Answer. Lake City is connected to 23 cities.