Suppose that your number has $n$ bits. Then taking the two’s complement can be done by subtracting it from $2^n$. For example, the two’s complement of $1101$ is
$$10000-1101=0011\;.$$
Note that the binary representation of $2^n$ is a $1$ followed by $n$ zeroes.
To see why it works, imagine that you start with a bit string $b_1b_2\ldots b_n$. After you flip the bits, you have another string, $\bar b_1\bar b_2\ldots\bar b_n$, say. If you add those two strings you get
$$\underbrace{11\ldots11}_{n\text{ ones}}\;.$$
Thus, if you flip the bits to get $\bar b_1\bar b_2\ldots\bar b_n$ and add $1$ to get the two’s complement, adding this two’s complement to the original string $b_1b_2\ldots b_n$ will give you
$$\underbrace{11\ldots11}_{n\text{ ones}}+1=1\underbrace{00\ldots00}_{n\text{ zeroes}}\;,$$
the binary representation of $2^n$. Consequently, you can get the two’s complement simply by performing the subtraction
$$1\underbrace{00\ldots00}_{n\text{ zeroes}}-b_1b_2\ldots b_n\;.$$