import std.stdio, std.string, std.conv, std.array, std.range, std.algorithm;

void main() {
  long[] xs = new long[](5);
  foreach (i; 0..5) {
    readf("%d\n", &xs[i]);
  }

  auto xss = permutations(xs);

  long ans = cast(long)1e10+7;
  foreach (ys; xss) {
    long t = 0;
    foreach (y; ys) {
      t += t % 10 == 0 ? 0 : 10 - (t % 10);
      t += y;
    }
    ans = min(t, ans);
  }

  writeln(ans);

}
