Answer: $43890=22\cdot 1995$
Take the obvious graph interpretation. For the example, take the complete bipartite graph with groups of $22$ and $1995$ vertices.
Now, let $A$ be the set of vertices, whose degree is greater than $22$. Let $B$ be the set containing the remaining vertices. See that there are no edges in $A$, so all the edges are either between $A$ and $B$ or in $B$. I will divide the proof in two cases:
Case 1. $|A|>22$
Since there are no edges in $A$, all edges have an endpoint in $B$. Thus, there can be at most $(2017-|A|)\cdot 22\leq 1994\cdot 22=43868$ edges.
Case 2. $|A|\leq 22$
Take the graph with the most edges within the given condition. Now, if there is an edge in $B$, which has an endpoint that is not connected to a vertex in $A$, one can delete this edge and add the edge between the endpoint and the vertex in $A$ without decreasing the total number of edges. Thus, one can assume that the graph with maximal number of edges contains all edges between $A$ and $B$, which means there can be at most $|A|\cdot(2017-|A|)+\frac{(22-|A|)(2017-|A|)}{2}=\frac{(22+|A|)(2017-|A|)}{2}\leq\frac{44\cdot 1995}{2}=43890$ edges, q.e.d.