#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  scanf("%d:%d", &x, &y);
  int ans = 0;
  while (1) {
    if (x % 10 == y / 10 && x / 10 == y % 10) break;
    ans++;
    y++;
    if (y == 60) {
      x++;
      y = 0;
    }
    if (x == 24) {
      x = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
