TITLE: How many different functions we have by only use of $\min$ and $\max$?
QUESTION [13 upvotes]: We can making many functions of three variable by only use and combining of $\min$ and $\max$ functions. But many of them are not different , like :
$$\min(x,y,z)=\min(x,\min(y,z)),\quad\min(x,\max(x,y))  = \min(x,x) = \max(x,x)$$  

How many different functions $\mathbb R ^3 \rightarrow \mathbb R$ of this form we have?     

The upper bound of numbers of this functions is $3^{3!}$ . Because there are only $3!$ states for $x , y , z$ like: $ x < y < z$ and $ x < z < y$ and ... and each state gives one of the values of $\{x,y,z\}$ .
And my second question is :   

How many different functions $\mathbb R ^n \rightarrow \mathbb R$ of this form we have ?

REPLY [8 votes]: Thanks to Giovanni Resta answer I will prove that $M(n)-2$ different functions of $n$ variable exist; Where $M(n)$ is $n$th number of Dedekind numbers.
At first it's simple to check :   
$\max(x,\min(y,z))=\min(\max(x,y),\max(x,z))$ 
$\min(x,\max(y,z))=\max(\min(x,y),\min(x,z))$
Now we can consider $\max(x,y)$ as $x \vee y$ and $\min(x,y)$ as $x \wedge y$ and then above identities convert to below familiar identities (distributive laws) :   
$x \vee (y \wedge z) = (x \vee y) \wedge (x \vee z)$
$x \wedge(y \vee z) = (x \wedge y) \vee (x \wedge z)$ 
Now number of OP functions with $n$ variable is equal to number of Free distributive lattice with $n$ generators without empty joins and empty meets.    
For example for $n=3$ from https://oeis.org/A007153 we have :
a
b
c
a or b
a or c
b or c
a or b or c
a and b
a and c
b and c
a and (b or c)
b and (a or c)
c and (a or b)
(a or b) and (a or c)
(b or a) and (b or c)
(c or a) and (c or b)
a and b and c
(a or b) and (a or c) and (b or c)