#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;




struct IntervalLeft{
  int64_t val;
  bool is_open;

  IntervalLeft(){}
  IntervalLeft(int64_t val, bool is_open): val(val), is_open(is_open){}

  inline int64_t get_left() const {return val + (is_open ? 1 : 0);}
};

ostream& operator<<(ostream &os, const IntervalLeft &rhs){
  os << (rhs.is_open ? "(" : "[") << rhs.val;
  return os;
}

bool operator==(const IntervalLeft &lhs, const IntervalLeft &rhs){return lhs.val == rhs.val and lhs.is_open == rhs.is_open;}
bool operator!=(const IntervalLeft &lhs, const IntervalLeft &rhs){return !(lhs == rhs);}
bool operator<(const IntervalLeft &lhs, const IntervalLeft &rhs){return lhs.val < rhs.val or (lhs.val == rhs.val and not lhs.is_open and rhs.is_open);}
bool operator<=(const IntervalLeft &lhs, const IntervalLeft &rhs){return (lhs < rhs) or (lhs == rhs);}
bool operator>(const IntervalLeft &lhs, const IntervalLeft &rhs){return !(lhs <= rhs);}
bool operator>=(const IntervalLeft &lhs, const IntervalLeft &rhs){return !(lhs < rhs);}


struct IntervalRight{
  int64_t val;
  bool is_open;

  IntervalRight(){}
  IntervalRight(int64_t val, bool is_open): val(val), is_open(is_open){}

  inline int64_t get_right() const {return val - (is_open ? 1 : 0);}
};

ostream& operator<<(ostream &os, const IntervalRight &rhs){
  os << rhs.val << (rhs.is_open ? ")" : "]");
  return os;
}

bool operator==(const IntervalRight &lhs, const IntervalRight &rhs){return lhs.val == rhs.val and lhs.is_open == rhs.is_open;}
bool operator!=(const IntervalRight &lhs, const IntervalRight &rhs){return !(lhs == rhs);}
bool operator>(const IntervalRight &lhs, const IntervalRight &rhs){return lhs.val > rhs.val or (lhs.val == rhs.val and not lhs.is_open and rhs.is_open);}
bool operator>=(const IntervalRight &lhs, const IntervalRight &rhs){return (lhs > rhs) or (lhs == rhs);}
bool operator<(const IntervalRight &lhs, const IntervalRight &rhs){return !(lhs >= rhs);}
bool operator<=(const IntervalRight &lhs, const IntervalRight &rhs){return !(lhs > rhs);}


struct Interval{
  IntervalLeft left;
  IntervalRight right;
  
  inline int64_t size() const {
    return right.get_right() - left.get_left() + 1;
  }
  
  static Interval make_open(int64_t left, int64_t right){
    return Interval({IntervalLeft(left,true), IntervalRight(right,true)});
  }
  static Interval make_closed(int64_t left, int64_t right){
    return Interval({IntervalLeft(left,false), IntervalRight(right,false)});
  }
  static Interval make_open_closed(int64_t left, int64_t right){
    return Interval({IntervalLeft(left,true), IntervalRight(right,false)});
  }
  static Interval make_closed_open(int64_t left, int64_t right){
    return Interval({IntervalLeft(left,false), IntervalRight(right,true)});
  }

  /**
   * @details 
   */
  static bool merge(const Interval &a, const Interval &b, Interval &ret){
    if(
       a.right.get_right() < b.left.get_left() or
       b.right.get_right() < a.left.get_left()
       ){
      return false;
    }

    ret = Interval({min(a.left,b.left), max(a.right,b.right)});

    return true;
  }
};

ostream& operator<<(ostream &os, const Interval &val){
  os << val.left << "," << val.right;
  return os;
}

vector<Interval> merge_intervals(const vector<Interval> &vals){
  vector<Interval> ret;
  
  for(auto &val : vals){
    if(ret.empty()){
      ret.push_back(val);
    }else{
      Interval res;
      if(Interval::merge(ret.back(),val,res)){
        ret.pop_back();
        ret.push_back(res);
      }else{
        ret.push_back(val); 
      }
    }
  }
  
  return ret;
}





int main(){
  int N,T;
  while(cin >> N >> T){
    vector<Interval> intervals;
    REP(i,N){
      LLI t; cin >> t;
      auto a = Interval::make_closed_open(t,t+T);
      intervals.push_back(a);
    }

    auto res = merge_intervals(intervals);

    LLI ans = 0;
    for(auto &x : res) ans += x.size();
    cout << ans << endl;
  }
  

  return 0;
}


Measured memory_bytes: 19560