#include <bits/stdc++.h>
using namespace std;
bool pal(string x) { return (x[0] == x[4] && x[1] == x[3]); }
string increase(string x) {
  stringstream hh, mm;
  int h, m;
  hh << x.substr(0, 2);
  mm << x.substr(3, 2);
  hh >> h;
  mm >> m;
  if (m == 59) h++;
  m++;
  m %= 60;
  h %= 24;
  string ret = "";
  if (h < 10)
    ret += '0', ret += (h + '0');
  else
    ret += (h / 10 + '0'), ret += ((h % 10) + '0');
  ret += ':';
  if (m < 10)
    ret += '0', ret += (m + '0');
  else
    ret += (m / 10 + '0'), ret += (m % 10 + '0');
  return ret;
}
int main() {
  string x;
  cin >> x;
  int cnt = 0;
  while (true) {
    if (pal(x)) break;
    x = increase(x);
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}
