#include <bits/stdc++.h>
using namespace std;
int main() {
  string time;
  int h = 0, m = 0, rh, p = 0, temp, k, count = 0;
  cin >> time;
  for (int i = 0; i < time.size(); ++i) {
    if (time[i] == ':') {
      p = 1;
      continue;
    }
    if (p == 0) {
      if (i == 0) {
        h = time[i] - 48;
      } else {
        h = h * 10 + (time[i] - 48);
      }
    }
    if (p == 1) {
      if (i == 3) {
        m = time[i] - 48;
      } else {
        m = m * 10 + (time[i] - 48);
      }
    }
  }
  rh = 0;
  p = h;
  while (p) {
    rh = rh * 10 + (p % 10);
    p /= 10;
    ++count;
  }
  if (count == 1) {
    rh *= 10;
  }
  p = 0;
  while (1) {
    k = h;
    rh = 0;
    count = 0;
    while (k) {
      rh = rh * 10 + (k % 10);
      k /= 10;
      ++count;
    }
    if (count == 1) {
      rh *= 10;
    }
    if (rh == m) {
      cout << p << endl;
      break;
    } else if (rh > m && rh <= 59) {
      cout << p + (rh - m) << endl;
      break;
    } else {
      p = p + (60 - m);
      if (h == 23) {
        h = 0;
      } else {
        ++h;
      }
      m = 0;
    }
  }
  return 0;
}
