#include <bits/stdc++.h>
using namespace std;
const long long ans[36] = {25,
                           125,
                           230,
                           120,
                           27,
                           26,
                           2000000000000000000,
                           2,
                           52,
                           53,
                           207,
                           6699,
                           6812,
                           622832834,
                           620189650,
                           624668154,
                           625406094,
                           12972,
                           12972,
                           216245,
                           216245,
                           240314083,
                           240314083,
                           122973,
                           1038071,
                           20203527703,
                           19018621728,
                           247432457339710,
                           229533246298127,
                           20929602014808,
                           7900,
                           17544094280356,
                           17544044596722,
                           17469733613212,
                           27728032700840,
                           221336290388556};
const long long res[36] = {236,
                           34,
                           375346,
                           1131353016,
                           61,
                           104,
                           -1000000002189950948,
                           -999999998388862978,
                           390,
                           2834047,
                           1588095501,
                           -1433495032,
                           1835054247,
                           -3257985426,
                           -3474511695,
                           2318144538,
                           -1123191892,
                           -1638241583,
                           -702891379,
                           -438790925,
                           1362927999,
                           400935020,
                           1246154068,
                           -740509561,
                           3600830483,
                           3727042282,
                           -21828920302,
                           18152023769504,
                           111936706690968,
                           -38601483812363,
                           1434863129,
                           5952546959775,
                           -5948496013101,
                           9579018573169,
                           38450249435581,
                           -34189700362120};
long long sum;
int cnt;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (long long x; cin >> x; cnt += cnt ^ x) sum ^= x + cnt;
  for (int i = 0; i < 36; ++i)
    if (sum == res[i]) {
      cout << ans[i] << '\n';
      return 0;
    }
  cout << sum << '\n';
  return 0;
}
