How fast will bullet hit the ground if it is shot vertically? The bullet can be normal AK-74 or M4 bullet. I am just interested to know how much speed it loses due to friction.
 A: The bullet will go upwards until stopped by a combination of gravity and air resistance. It will then fall and reach a terminal velocity (maximum speed) which is the speed where the air resistance matches the force of gravity. 
The Wikipedia article on celebratory gunfire states:

Firearms expert Julian Hatcher studied falling bullets in the 1920s
  and calculated that .30 caliber rounds reach terminal velocities of 90
  m/s (300 feet per second or 186 miles per hour). A bullet traveling
  at only 61 m/s (200 feet per second) to 100 m/s (330 feet per second)
  can penetrate human skin.

A .30 calibre round is 7.62mm whereas AK-74 and M4 carbines fire 5.45/5.56mm rounds. The lighter rounds will fall more slowly due to higher air resistance compared with weight. They also weigh a lot less (I think about 3 times less, but it will depend on the round - I am sure the gun experts will correct me here if I am too specific). So they will be a lot less lethal.
A: Approximate estimation for an AK-47 bullet
Terminal velocity formula is :

Bullet parameters from 7.62×39mm cartridge:


*

*Mass 0.0079 kg

*Length 0.0268 m

*Diameter 0.0079 m

*Drag coefficient ~ 0.125 of G7 projectile model under bullet sub-sonic speeds < 1 mach


Bullet projected area calculation:


*

*Minimum projected area is bullet's cross-section, i.e. circle area 0.000049016699 m^2

*Maximum projected area is length*diameter 0.00021172 m^2

*Average projected area is 0.6*min_area + 0.4*max_area 0.000114098020 m^2


Why we need averaged projected area ? Because bullet when falling down experiences tumbling (in case shot vertically), so projected area will switch from a minimum value to a maximum value and vise-versa over time. Thus we need projected area averaging. 
Second note - maximum area will not be strictly a rectangle, that's why I've used 0.6, 0.4 weights (instead of 0.5,0.5) for an area averaging so that averaged area would be slightly shifted to a minimum value.
Plunging all the numbers into the formula gives the answer of
94    m/s.
Notes :


*

*In general drag coefficient depends on bullet speed. For speeds under 1 mach drag coefficient is a constant. I made an assumption that falling bullet
will not reach super-sonic speeds. It may be true, but not verified

*Drag force depends on flow density, in this case air density. Air density is a function of an altitude. And density is smaller at higher altitude, thus making drag force smaller. So either it will make terminal speed of the bullet bigger or at least bullet will reach terminal velocity faster. Either way, calculations should be more complex than this.
