#include <bits/stdc++.h>
using namespace std;
string convert(int t) {
  string res;
  if (t < 10) res = "0";
  stringstream ss;
  ss << t;
  res += ss.str();
  return res;
}
int main() {
  int h, m;
  char s;
  cin >> h >> s >> m;
  int cnt = 0, Min = 0, hours = 0;
  for (int i = 0; i < 1450; i++) {
    string H, M;
    H = convert(h);
    M = convert(m);
    if (H[0] == M[1] && H[1] == M[0]) {
      cout << cnt << endl;
      break;
    }
    cnt++;
    m++;
    if (m == 60) {
      h++;
      m = 0;
    }
    if (h == 24) h = 0;
  }
  return 0;
}
