Math behind helium balloons lifting objects to (almost) space So I've seen those big helium balloons that are not even filled all the way up, but they still manage to reach heights of up to 30 km. I think they're mainly used for research and etc. Furthermore, I also have noticed that because of the lower pressure higher in the atmosphere helium expands and balloon seems filled up. How do you actually find maximum volume of the balloon according to the height that it has to reach and temperature at that height? And how much helium do you need according to the mass that the balloon has to carry?
 A: Take a look at the ideal gas law and Archimedes' principle.

How do you actually find maximum volume of the balloon according to the height that it has to reach and temperature at that height? 

The ideal gas law describes how the volume of a gas varies with amount, in mol, of gas particles, pressure, and temperature. You should be able to calculate the volume of helium at high and low altitudes by searching for the pressures and temperatures at those locations. Note that the gas pressure is of the helium in the balloon. This is only slightly larger than the surrounding air (atmospheric) pressure due to any surface tension in the balloon, so we can take the two to be roughly equal.

And how much helium do you need according to the mass that the balloon has to carry?

Archimedes' principle allows you to calculate the upthrust on an object in a fluid (a liquid or gas).
The upthrust is determined by the volume of the object (in this case the volume of the air balloon), and the density of the fluid (here the density of the air at different altitudes).
In order for the balloon to be able to float, the upthrust must be at least as large as the weight of the balloon (the combined mass of the gas and the load).

As I said earlier, the pressure inside the balloon at a particular altitude will be basically the same as the atmospheric pressure if we ignore any additional surface tension from the balloon itself and think of it more like a plastic bag than a stretchy elastic balloon.
To determine how much helium gas we need, we need to consider the necessary buoyancy required.
Let the volume of helium in the balloon be $V$. This is also, let us say, the volume of air displaced (assuming the volume of payload is negligible in comparison). This means that the weight of air displaced by the balloon, which Archimedes' principle says is the upthrust, is
$$W_\text{air displaced} = B = V\rho g.$$
Note that I will use $B$ for buoyancy (upthrust) so as to not get confused with $T$ for temperature.
It turns out that this upthrust is independent of the altitude of the balloon. This is because the volume of the balloon increases in proportion to the temperature and inversely proportional to the atmospheric pressure, whereas the density of the air increases proportionally to the atmospheric pressure and inversely proportionally to the temperature, so that they cancel out.
Note that this assumes the air behaves ideally (obeys $PV = nRT$), and, as we said before, the balloon exerts no additional pressure on the helium gas (if we had a metal balloon, the buoyancy would decrease with altitude of course since the volume of helium would be fixed but the air density would be decreasing).
Now how can we use this to calculate the volume of helium gas? Well, in the limiting case, the upthrust force will just balance the weight of the balloon, so we can say that:
\begin{align}
Mg &= V\rho g \\
\implies M &= V\rho
\end{align}
where $M$ is the total mass of the balloon.
We can express this total mass as that of the helium gas and that of the payload.
$$M = m_\text{payload} + m_\text{helium}$$
The mass of the helium can be calculated from the number of moles which we can calculate using the ideal gas equation:
\begin{align}
PV &= nRT \\
\implies n &= \frac{PV}{RT}
\end{align}
where $R$ is the gas constant $= 8.314\text{J}\text{mol}^{-1}\text{K}^{-1}$.
And to convert from moles to mass we use the molar mass of helium, $M_h = 4\text g \text{mol}^{-1}$, to give that
$$m_\text{helium} = n\cdot M_h = \frac{PVM_h}{RT}.$$
Therefore
$$m_\text{payload} + \frac{PVM_h}{RT} = V\rho.$$
Which we can re-arrange for the volume of helium:
$$V = \frac{m_\text{payload}}{\rho - \frac{PM_h}{RT}}\tag{1}\label{1}$$
We are now in a position to calculate how much helium we need!
According to this source, the temperature at sea level is $15.0$C $ \approx 288.2$K, the pressure is $101$kPa, and the density is $1.23\text{kg}\text{m}^{-3}$. At an altitude of $30$km, the temperature is $-46.6$C $\approx 226.9$K, the pressure is $1.20$kPa, and the density is $0.0184\text{kg}\text{m}^{-3}$.
Using the atmospheric data for sea level and a payload mass of $5\text{kg}$ (seems somewhat reasonable), the volume comes out as
$$V = \frac{5}{1.23 - \frac{101\times 10^3 \times 0.004}{8.314 \times 288.2}} = 4.71\text m^3.$$
Note that the pressure was converted from kPa to Pa, and the molar mass from gmol$^{-1}$ to kgmol$^{-1}$.
This sounds about right - roughly the capacity of a hot tub. (If you're sceptical, I checked Equation \ref{1} with these calculations.)
So how large will the balloon be at its peak?
The most straightforward approach would be to sub-in the conditions at an altitude of $30$km to Equation \ref{1}. This would give us a volume of:
$$V = \frac{5}{0.0184 - \frac{1.20\times 10^3 \times 0.004}{8.314 \times 226.9}} = 315 \text m^3.$$
Alternatively, we could calculate the amount of gas in the initial volume at sea level ($4.71\text m^3$) and then see what volume this amount of gas would occupy when subjected to the higher pressure and lower temperature at $30$km. This is assuming that no helium escapes the balloon.
The ideal gas equation can be used to calculate the moles at sea level.
$$n = \frac{PV}{RT} = \frac{101 \times 10^3 \times 4.71}{8.314 \times 288.2} = 199\text{mol}.$$
We can now use the atmospheric conditions at $30$km, with this amount of gas, to see the volume up there:
$$V = \frac{nRT}{P} = \frac{199\times 8.314 \times 226.9}{1.20 \times 10^3} = 312\text m^3.$$
Which differs slightly from our previous result based on the $30$km buoyancy calculation due to inaccuracies in the air density value at $30$km.

But do we need to use a density value at all?
Going back to Equation \ref{1}... Let's face it, that equation is ugly. We need all of the density, pressure and temperature of the atmosphere at an altitude to calculate the volume of the balloon at that height. And although this data is readily available, as we have found, it is not all that accurate. Technically once we calculate the amount of helium in the balloon at sea level, we only need readings for temperature and pressure at the higher altitude, not density, as we saw in the second calculation which lead to $312\text m^3$.
However, do we need any density measurement at all?
Since we are already assuming that the air in the atmosphere behaves as an ideal gas, we do not. We know the molar mass of air (an average molar mass as it is a mixture of different compounds) to be $M_a = 28.97\text g \text{mol}^{-1}$.
And if we know this then we can calculate the density of the air at a particular altitude using the ideal gas equation, if we know the pressure and temperature at that altitude.
\begin{align}
PV &= nRT \\
\implies \frac{n}{V} &= \frac{P}{RT} \\
\rho &= \frac{m_\text{air}}{V} \\
&= \frac{n\cdot M_a}{V} \\
&= \frac{PM_a}{RT}
\end{align}
We can now simplify Equation \ref{1} greatly:
\begin{align}
V &= \frac{m_\text{payload}}{\rho - \frac{PM_h}{RT}} \\
&= \frac{m_\text{payload}}{\frac{PM_a}{RT} - \frac{PM_h}{RT}}.
\end{align}
Giving that
$$V = \frac{m_\text{payload}RT}{P(M_a - M_h)} \tag{2}\label{2}.$$
This equation, Equation \ref{2}, is superior to Equation \ref{1}. We now only need the temperature and pressure at an altitude in order to calculate the volume of the balloon. No density value required.
